11 Vote

Rename Files sequentially keeping "connected" File Names Pattern

Question by BANANAKID | Last update on 2023-02-14 | Created on 2023-02-14

I'm trying to reorganize photo library that contains edited files as well as originals. I already achieved desired folder structure using AmoK Exif Sorter, i.e %UserProfile%\Photos\%year%\%month%\%day%.

Each %day% folder contains photo image files with a little bit different name pattern:

ZMGM00003 (Edited).jpg
IMG_0002 (Edited).jpg

I'd like files to be named sequentially but keeping relevant " (Edited)" suffix:

DSC_0002 (Edited).jpg
DSC_0004 (Edited).jpg

So far in FileRenamer (which can now restart numbering sequence in each new folder) I came up with regular expression to rename "*.jpg" and "* (Edited).jpg" preserving it's "suffix" part when it's there (" (Edited)"):

- find string     ^(\D+)(_)?(\d+)(Edited)?
- replace string  DCS_%000num%$4

However I get sequential numbering across all files and thus the relevance of edited files is lost:

DSC_0003 (Edited).jpg
DSC_0005 (Edited).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?

Thank you for File Renamer, Stefan Trost!

P.S. I've got like 80000+ family photos since late 90's, it would take ages to process by hand.

P.P.S. Something like this could be helpful (not found in FileRenamer) - https://www.advancedrenamer.com/user_guide/filepairs

22 Votes

The easiest way is just to go without the automatic numbering function since the numbers are already there.

For example with the following regular expressions in the Changes > Search and Replace function of the FileRenamer:

Search for:   ^.*([0-9]{4})
Replace with: DSC_$1

I don't know how your other files are named, but this is working for your example files.
2023-02-15 at 03:49

ReplyPositive Negative
00 Votes

Thanks for response, Stefan! While the regex code is sleeker indeed, it provides the same output as the one I managed to put together. I will accomplish my goal using "pair renaming" option of Advanced Renamer I linked in P.P.S., just will need extra steps to rename everything back & forth. However I very much prefer to use FileRenamer. Please consider implementing paired files renaming support. If would be extremely cool to have a pairs match either by extension (like Advanced Renamer can do) or partial file name match (like in my initial question).
2023-02-15 at 09:55

Positive Negative
11 Vote

Then you have done something else. I used exactly that regular expression shown in my answer and it was exactly the result that you wanted to have for your example files.

And this funtion only applies for numbering? Such as, don't increase number for same named files?
2023-02-15 at 23:13

Positive Negative
00 Votes

The function you recommend

Search for: ^.*([0-9]{4})
Replace with: DSC_$1

( result image - https://pixeldrain.com/u/hnxox7TT )

for my example provides result not close to

Search for: ^(\D+)(_)?(\d+)(Edited)?
Replace with: DCS_%000num%$4

( result image - https://pixeldrain.com/u/LDet9Rjw )

while required goal is as described in end of opening post

( result image wanted - https://pixeldrain.com/u/X8GVnRUP ).

Yes, the function in question should only apply to numbering and the function should not increase number for same named files (or similarly named, i.e. files with and without suffix/prefix should receive same number and keep suffix/prefix).

Example of function with close interpretation can be found in Advanced Renamer - https://www.advancedrenamer.com/user_guide/filepairs (but it works only for same named files with different extensions). If you could include at least same function as Advanced Renamer, then FileRenamer will get way more powerful! According to my research, only Advanced Renamer has function like this.

P.S. Sorry for lacking code markup, I cannot find reference to it in help of this forum.
Last update on 2023-02-16 | Created on 2023-02-16

Positive Negative
11 Vote

One the one hand, in your screenshots, you are using another file order compared to your post. On the other hand, what is the most important part, is that you have forgotten to check the "Interpret as Regular Expression" option. If this option is not activated, the string is searched and replaced as it is. Since in your case, the regular expression is not part of any file name, it results in no changements.

What do you think about two options, one for "the entire file name" and one for "the same beginning of the filename". That would fit for your example files like "IMG_0001" versus "IMG_0001" + " (Edited)". Otherwise you would have to specify what the "prefix" should be which is making it more complicated for the user and even also not applicable for your example files. What do you think? Or would there be any problems or thinks that could not be resolved with a solution like that?

PS: You need to have some accepted posts to get an HTML editor for your posts which includes the code markup option. We have edited your post accordingly.
2023-02-17 at 01:36

Positive Negative
00 Votes

Sorry, I definitely forgot to check the box. I was surprised it didn't work because I tried this yesterday and it worked. You are very correct here.

I think the idea to implement this without prefix but with both "entire file name" and "the same beginning of the filename" ("file name + suffix") is OK because these are most common scenarios (not only photos but backup and invoice files usually have similar patterns).

I think it may be tricky because something related to file extension has to be addressed as well. FileRenamer should decide what to do if the "the same beginning of the filename" is same and file extensions are different. I think FileRenamer should always respect "the same beginning of filename" over extension. This will provide basic flexibility and won't make user dizzy of the options. Also since "the same beginning of the filename" is actually prefix, those who really need it can manage to get prefix scenario with one extra step (which is OK).

I got it regarding markup, thank you for explanation!
2023-02-17 at 05:25

Positive Negative
1Best Answer1 Vote

I have just published a new version of the FileRenamer containing both mentioned new options. You can download it from my website as of now.

The options can be found in the menu "Settings > Numbering".

However, there is one thing to keep in mind when working with the "same name root" option. For a file order like "File", "File - Edit 1" and "File - Edit 2" it is working as expected. But when using a order such as "File - Edit 2", "File - Edit 1", "File" it is not detecting "File - Edit 2" as belonging to the other files because the program only checks for the neighbor files in the list (otherwise you would have to check the complete list for each file or you are faced with the problem of how many characters are to be compared again).

This is no problem with the other option, since the order of same-named-files does not play any role.

What do you thing about the new functions?
2023-02-23 at 23:23

Positive Negative
00 Votes

Dear Stefan, sorry for the delay, I've been battling memory leak via WPA and it was quite an adventure. The new function works as advertised, thank you so much! I will report here in case I'll find a bug during intensive use.

I also have an improvement idea that is nothing new but probably it's worth implementing in the future. That is addition to rename based on EXIF data (not all but most common). If this can be done without including a whole exiftool code, certainly.

I also will add a tiny bug report here as well. I'm using Windows 10 version 21H2 with HiDPI screen at 200% UI scaling of operating system. When I check "save window size and position" option in FileRenamer and save profile to program's folder (as start.frs), the next time I open FileExplorer the window becomes almost maximized and occupies almost entire screen. So there's something wrong with saving or reading window position and size. This happens when program has HiDPI compatibility set to Application or not set (in EXE properties › Compatibility › Change High DPI Settings). If I set program High DPI scaling override to System or System (Enhanced) then saving window position and size works correctly. Unfortunately if System is used the program UI becomes pixelated, if System (Enhanced) is used program UI is mostly OK (most of text is OK) but in some places it's still 0.5× the resolution (so pixelated). Please have a look once you've got a spare minute! Fixing this will make UI more polished. Here's screenshot of System (Enhanced) override — https://pixeldrain.com/u/unimi18P
2023-02-27 at 19:40

Positive Negative
00 Votes

Hello Stefan, maybe you'll find interesting the following though it's not related to the discussed question and new function. I've been renaming many files in many (thousands) of directories at once and an SV error dialog appeared for 3 folders. I couldn't figure out what's wrong with them until I found they all have hidden .XnSort file in them (file is OK, it's XnView MP file). It would be handy if SV error dialog would tell what's wrong because now it says it just cannot rename 2 files that should be renamed no problem, and it says that for each file in a folder with the hidden .XnSort file. So it takes a lot of time to close the dialog with OK button. Sorry my Snipping Tool broke for no reason (it produces just black window screenshot so no screenshot of SV dialog) but I hope you understand this explanation. It's sor of a bug but not at all. I succesfully renamed files in folders (without altering FileRenamer preset) once I deleted .XnSort file. Oh, it's important that I used RegEx to rename files. Maybe a workaround is to create a checkbox like "Don't include hidden files" in the "Search Folder" dialog window?
2023-03-24 at 19:25

Positive Negative
00 Votes

What do you mean with SV error? Which version are you using? The newest one?
2023-03-24 at 19:39

Positive Negative
00 Votes

I have tested version 23.6.13 and HiDPI bug is fixed. The program now correctly restores it's window size and position at 200% UI scaling in Windows 10. Thank you, Stefan!
2023-06-25 at 01:00

Positive Negative

Related Topics

Rename File to its Folder Name

Tutorial | 0 Comments

PHP: File Download Script

Tutorial | 0 Comments

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own article on askingbox.com. That’s how it’s done.