I have a series of image files with a set prefix that I would like to remove. Example of the filenames that I will have:
- Image_2022-06-09-12-29-00_Filename-01
- Image_2022-07-09-13-29-59_Filename-02
- Image_2022-02-11-09-26-31_Filename-03
I would like them to turn into:
- Filename-01
- Filename-02
- Filename-03
I currently have a .bat file that manages to remove the first part of all the files which can either be .jpg or .png files:
set current_dir=%cd%
powershell -Command "get-childitem *.png | rename-item -newname { [string]($_.name).substring(26) }"
powershell -Command "get-childitem *.jpg | rename-item -newname { [string]($_.name).substring(26) }"
My problem now however, is that once I run this and the files are renamed, I cannot copy in new files and run the .bat file again because it will rename the files that have already been renamed. Is it possible to identify a sequence of the first part of a filename, and then apply this only to those files? The first 26 characters will always be in that format, but the numbers may change.