Batch rename of files in all subdirectories with Powershell

Well here is what you have to do if you want to rename all files and replace the filename with an incremental number.

The following example renames all .wav files starting from number 1:

$i=1
Get-ChildItem *.wav | %{Rename-Item $_ -NewName ('{0:D4}.wav' -f $i++)}

Recursively the same task:

$i=1
Get-ChildItem -r *.wav | %{Rename-Item $_ -NewName ('{0:D4}.wav' -f $i++)}

Sorting by time:

$i=1
Get-ChildItem -r *.wav | sort LastWriteTime | %{Rename-Item $_ -NewName ('{0:D4}.wav' -f $i++)}

 

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply