I have a folder of bulk jpg files that are numbered counting up starting from 001 but there are files that get deleted or replaced in the middle. So I am needing to bulk rename the files, first removing the existing suffixes and then adding a new 3 digit counter suffix.
Example
Image Image 001.jpg
Image Image 022.jpg
Image Image 078.jpg
Image Image 113.jpg
Desired Result
Image Image 001.jpg
Image Image 002.jpg
Image Image 003.jpg
Image Image 004.jpg
I got very close to the first half of what I wanted using this script, to remove a few characters from the suffix, except it was creating the same file name for every file and errored.
Get-ChildItem 'C:\New Folder' -filter *.jpg | rename-item -NewName {$_.name.substring(0,$_.BaseName.length-4) + $_.Extension }
I don't know how to add a counter suffix at all. It would honestly be good enough to have and run 2 scripts... this one first, and a second to add the counter afterwards. Thanks in advance!