How to change the file extension of multiple files?
Yesterday, I was learning Data Visualization on FreeCodeCamp. So I have this habit of keeping a log of whatever I write, read, listen & watch on the internet (will write back story another time 😉). FreeCodeCamp gives us an option to save the exercise code as a .txt
file. So while that is helpful but you probably would not want to save a .js
file as .txt
. Luckily, you can change the extension of all your files simultaneously.
-
Open Windows Powershell in the folder where you have all the files you want to change the extension of. To open that, click on
File
in the top-left corner. Then click onOpen Windows Powershell
. -
Suppose you want to change all the
.txt
files into.html
, then runningGet-ChildItem *.txt
will get all the files in the current folder that have a.txt
file extension. -
To do all the work with a single line, run -
Get-ChildItem *.txt | Rename-Item -NewName { $_.Name -replace '.txt','.html' }
Now all the .txt
file extensions are replaced with .html
& you can check that either by running Get-ChildItem *.html
or by simply looking inside the folder with file explorer.
If you found this article helpful, I would be grateful for your support.
"Buy me some paneer curry"