0

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!

Kamil Maciorowski
  • 69,815
  • 22
  • 136
  • 202
  • Seems like a program like [Advanced Renamer](https://www.advancedrenamer.com/) would make things like this much easier. See [screenshot example](https://i.stack.imgur.com/PIb2X.png) – Blind Spots Jan 17 '23 at 21:43
  • Or Bulk Rename Utility, https://www.bulkrenameutility.co.uk/ ,free for non-commercial use – DrMoishe Pippik Jan 18 '23 at 00:58
  • Thank you both for the program suggestions! I would have never found those on my own, I plan to run some tests with them this week :) – Sunshinefox Jan 18 '23 at 07:07

0 Answers0