Sunday, October 25, 2015

Batch file renaming using power shell

About batch renaming of files, this code enables you to change things like eg. all spaces to underscore "_", or even roll forwarding years such as changing all "2014" to "2015".

1
Open windows power shell

2
Navigate to your folder using the following commands:

cd "<folder>"

eg.

cd C:\folder\

3
Then enter the command which replaces all the space with underscore "_"

Dir | Rename-Item –NewName { $_.name –replace “ “,”_” }

You can also customise accordingly. The following replaces all 2014 with 2015:

Dir | Rename-Item –NewName { $_.name –replace “2014“,”2015” }

No comments: