Tag Archive for: 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++)}