Rename all files in a directory, and add a counter to each name.
Without Aliases
Get-ChildItem | ForEach-Object -Begin { $i = 0 } -Process {
Rename-Item -Path $_ -NewName ("someNewName-" + $i + $.Extension); $i++; }
With Aliases
dir | % -b { $i = 0 } { rni $ -new ("someNewName-" + $i + $_.Extension); $i++; }
If you're working with JPEGS, the result will look something like this:
someNewName-0.jpg someNewName-1.jpg someNewName-2.jpg someNewName-3.jpg someNewName-4.jpg someNewName-5.jpg someNewName-6.jpg someNewName-7.jpg someNewName-8.jpg someNewName-9.jpg
See also:
- Rename-Item http://technet.microsoft.com/en-us/library/hh849763.aspx
- about_Quoting_Rules http://technet.microsoft.com/en-us/library/hh847740.aspx