A simple powershell script to bulk rename files in a folder in Windows 7

In this post I'm showing you how to buld rename a set of files in a folder. I'm using a powershell script to do this. Save the following script in a file with '.ps1' extension.

$files=dir *.wmv
foreach($file in $files){
 write-host $file.Name
 rename-item -path $file -newname (""+$i+".wmv")

"Dir" is for taking the file list in the directory with *.wmv extensions ( you have to change this according to your needs).
Then run the script using the following command.
powershell -executionpolicy bypass .\rename.ps1

ExecutionPolicy part is necessary so the Powershell wouldn't request us for signatures.

Popular Posts