I'm trying to reorganize photo library that contains edited files as well as originals. I already achieved desired folder structure using Exif Sorter, i.e %UserProfile%\Photos\%year%\%month%\%day%
.
Each %day%
folder contains photo image files with a little bit different name pattern:
IMG_0001.jpg
ZMGM00002.jpg
ZMGM00003 (Edited).jpg
ZMGM00003.jpg
IMG_0002 (Edited).jpg
IMG_0002.jpg
IMG_0004.jpg
I'd like files to be named sequentially but keeping relevant " (Edited)
" suffix:
DSC_0001.jpg
DSC_0002.jpg
DSC_0002 (Edited).jpg
DSC_0003.jpg
DSC_0004 (Edited).jpg
DSC_0004.jpg
DSC_0005.jpg
So far I came up with regular expression to rename "*.jpg
" and "* (Edited).jpg
" preserving it's "suffix" part when it's there (" (Edited)
") (sorry I use RegexRenamer because I'm beginner):
^(\D+)(_)?(\d+)(Edited)?
DCS_$#$4
However I get sequential numbering across all files and thus the relevance of edited files is lost:
DSC_0001.jpg
DSC_0002.jpg
DSC_0003 (Edited).jpg
DSC_0004.jpg
DSC_0005 (Edited).jpg
DSC_0006.jpg
DSC_0007.jpg
Is there any way I can rename files and preserve filename "connection" pattern between them, i.e. so I get DSC_0002 (Edited).jpg & DSC_0002.jpg
instead of DSC_0002 (Edited).jpg & DSC_0003.jpg
?
Since I've got thousands of folders, the renaming should be recourse & sequence should restarted with each new folder. I believe this requires PowerShell or batch scripting that will determine required condition but I'm not sure where to start. I am open to ideas like maybe I could process file names via Excel first and then batch-rename from TXT/CSV file.
P.S. I've got like 80000 family photos since late 90's, it would take ages to process by hand. I can run anything in Windows and macOS to solve this (would prefer Windows though).
I'd like to answer my own question because I managed to resolve the problem with the help of the awesome Stefan Trost and his FileRenamer application. Basically Stefan has implemented the feature from scratch and it is available to everyone for free.
Here're FileRenamer settings in case anyone struggles with the same problem in the future:
Settings
Numbering
Reset numbering with every new folder On
Do not increase at files with the same name in the file list one after the other On
Do not increase at files with the same name root in the file list one after the other On
And here're regular expression and it's settings in main window:
Name
Search for: ^.*([0-9]{2})
Replace with: IMG_%000num%
Interpret as Regular Expression: On
This will go through all sub-folders or folders and rename every file according to the pattern and keeping unique suffixes, just as described in opening post:
DSC_0001.jpg
DSC_0002.jpg
DSC_0002 (Edited).jpg
DSC_0003.jpg
DSC_0004 (Edited).jpg
DSC_0004.jpg
DSC_0005.jpg
P.S. Here's a link to my request at FileRenamer support portal so nobody thinks this post is an advertisement.