Shubham
Ramdeo


December 18, 2018

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.

How to change extension of multiple files with 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 :)


You might also like:

(prev)
(next)

(rand) Operators Introduction
(rand) Simple DIY Pickup to record musical instruments
(rand) Bitwise Operators

© Shubham Ramdeo, 2020
you are really awesome!

Site Designed with Beauter🌸