fuddlepixelFuddlepixel coz tech is fun();

How to change extension of multiple files with PowerShell

A super easy windows trick to change extension a batch of all the files in a directory using PowerShell.

By Shubham Ramdeo
18 December 2018 · 1 min read
# windows  powershell  tricks 

How to change extension of multiple files with PowerShell

Programmers sometimes come across a lot of labor work! One of the hardest things is to manually write and rename files up. For windows, we don’t have such a popular and equipped shell system as LINUX does, but still, we’ve got PowerShell.

Suppose there is a problem. You have a folder containing a lot of HTML files. Now to upload it, you want to change the extensions of all the hundreds of files from .html to .php. Let’s see how can you do it windows quickly.

First, open the folder which contains all the files.

Then at the top left corner of the directory explorer, you can see the File Menu. Click and select Powershell.

Now simply enter the following command:

Dir *.html | rename-item -newname { [io.path]::ChangeExtension($_.name, "php") }

That’s it!

Be sure to change html and php to those you want to change. A more general command would be like:

Dir *.old_extension | rename-item -newname { [io.path]::ChangeExtension($_.name, "new_extension") }

Where the old_extension and new_extension are to be replaced with the real extension of your case.

Of course, you can directly run PowerShell from the start menu and use cd command to move across directory.

I hope this little trick might save some time for you :)

Share this :

Update me weekly ✉

Subscribe below and we’ll send you a weekly email summary of all new Code tutorials. Never miss out on learning about the next big thing.

I'm in ♥

Or follow us

About author

Shubham Ramdeo

Shubham Ramdeo

Shubham Ramdeo is the founder of Fuddlepixel. He is a geek, a writer, involved with many technical and humanity projects.

Meet me!