Renaming image with variable contents

Bulk Rename Utility How-To's

Renaming image with variable contents

Postby drhansenjr » Thu Jun 01, 2023 2:05 am

I have not worked with regex in a very long time and have a folder with thousands of image files that need to be renamed. Some are in a format such as DSC_999.JPG and others in the format DSC_999_1.JPG, DSC_999_2.JPG etc. What I need is to be able to rename these files as follows: DSC_999_RESIZED_[DATE-TAKEN]_[EXTRA DIGIT].JPG, etc, where [DATE-TAKEN] is the EXIF date from the image in the format YYYYMMDD. I am at a loss to figure out how to accomplish this. All help would be appreciated!

DH
drhansenjr
 
Posts: 1
Joined: Thu Jun 01, 2023 1:43 am

Re: Renaming image with variable contents

Postby therube » Fri Jun 02, 2023 5:08 pm

Various "exif:DateTime" are available with 7:Add.

10:Numbering should handle your extra digit.
Or by "extra digit", do you mean the _1, _2, ... ?


Start with that & see if you can get at least some of the data in there you want.
("Start", as in see that you're getting the wanted data, not necessarily that you'd want to rename yet, at this point.)
(I'm not familiar with exif, so not sure just how the data garnered will end up?)


And maybe post a few diverse actual filenames.
therube
 
Posts: 1319
Joined: Mon Jan 18, 2016 6:23 pm

Inserting metadata

Postby Luuk » Fri Jun 02, 2023 5:27 pm

Its unfortunate, but since RegEx(1) can never see a file's metadata, he can only rename like...
DSC_999 -------> DSC_999_RESIZED
DSC_999_1 ----> DSC_999_RESIZED_1

The AutoDate(8) can see metadata, but he will only prefix or suffix this metadata onto the new-names.
The Add(7) can also see metadata, with things like <(metadata)>, but he can only prefix, suffix, or insert.
So the best way will depend on your filenames, and you might also need to conduct more than just 1-rename.

This an example to conduct only the names with having exactly 3-digits in DSC999 for just 1-rename...
First, the Filters(12) needs a checkmark for "RegEx", so then a "Mask" like ^DSC_\d{3}(_\d)?\.jpe?g$
Then clicking the blue-arrows beside "Mask" will present only these names inside of the file-listing.

Then Regex(1) could use a "Match" and "Replace" like...
^(DSC_\d+)((_\d)?)$
\1_RESIZED\2

Add(7) will need an "Insert"==<_($exif:DateTimeOriginal)> with "at"==16.
AutoDate(8) needs "Custom"==%Y%m%d and making sure "Mode"==None.
NOTE: The $ tells Add(7) to use AutoDate(8)'s date-format!

So this method conducts everything in 1-rename, but only conducts names with exactly 3-digits in DSC999.
To conduct names like DSC1234, must edit the "Mask", changing 3-->4 so then clicking the blue-arrows.
Would also need to edit Add(7)'s "at" from 16-->17, since he wont conduct any regex.


Another way: Prefix your dates to all of them in 1-rename, and then let RegEx(1) fix them all with a 2nd-rename.
But of course the "Mask" would need to change, so really it just depends on which method might be the easiest??
This what therube means by saying to maybe post a few diverse actual filenames.
Luuk
 
Posts: 706
Joined: Fri Feb 21, 2020 10:58 pm


Return to How-To