Sample Header Ad - 728x90

Replacing counter in a filename for all files in a directory

7 votes
4 answers
1172 views
After importing several 1000 Files from a camera onto a hard drive I realized, that the counter, used in the process of renaming the file - does not start from 0. This leads to file structure like this:
My vacation 2018-05-03 2345.jpg
My vacation 2018-05-03 2346.jpg
My vacation 2018-05-04 2347.jpg
I would like to batch rename all those files in a wax, that the index starts with 0
My vacation 2018-05-03 0001.jpg
My vacation 2018-05-03 0002.jpg
My vacation 2018-05-04 0003.jpg
I went already through some topics dealing with batch renaming files and **adding** an counter/index (bash loop) or usig **rename/prename** but I was not able to get a working solution for my case. Basically, I would like to match the part of the filename with the description and the date using the regular expression .*(\d\d\d\d\-\d\d\-\d\d){1} and add a suffix counter on the end.
Asked by karlitos (181 rep)
Nov 7, 2021, 04:45 PM
Last activity: Nov 9, 2021, 05:08 PM