Changing photo date data from date in file name

Started by obscuritea, August 04, 2021, 04:05:15 AM

Previous topic - Next topic

obscuritea

Admittedly, I barely know how to use the command line so I've been struggling here! Using exiftool in terminal on MacOS.

I have a folder of photos in the following format: photo_1@26-09-2019_13-25-38.jpg, in which the first set of numbers is equivalent to the date, and second set of numbers to the time in 24hr format, I believe. So this example would be Sept. 26, 2019, 13:25:38. I am trying to change the FileModifyDate tag (when I list all the tags for the photo I don't see any creation date tags, just this one) to the relevant date, since currently all the photos have the same FileModifyDate- the date they were saved to my computer. I don't need to add the time info to the corrected data, I just need to correct the dates, time can be set to a default 00:00.

I tried the following: exiftool '-FileModifyDate<filename' DIR , DIR in this case being the example file I am testing with, but it failed since it thinks the last set of numbers (13-25-38 in my example file above) is the date and knows 13 isn't a valid month. How can I extract the date from the first set of numbers in their DD-MM-YYYY format? I've seen a couple similar posts here on the forum, but I get stuck at how to edit this command to pull the data from my particular filename's format.

Thank you!

StarGeek

In order to copy like that, the time values need to be in order from the largest (Year) to the smallest (second).  Additionally, your example shows a leading extraneous number which would interfer with a direct copy from the Filename into the FileModifyDate.

As long as the filename format is exactly as you show, the leading characters up until the @ sign can be stripped away and then the date data can be reorganized with this command
exiftool '-FileModifyDate<${Filename;;s/^.*@//;s/(\d\d)-(\d\d)-(\d{4})(.*)/$3$2$1$4/}' /path/to/files/

But you might also check your files to see if there's an embedded timestamp that might be easier to copy.  Try running this command on one of the files
exiftool -time:all -G1 -a -s photo_1@26-09-2019_13-25-38.jpg

If the images are from a camera and the metadata hasn't been purposefully stripped away, there's a good chance you'll see something like this
[System]        FileModifyDate                  : 2019:03:30 09:48:02-07:00
[System]        FileAccessDate                  : 2021:08:04 08:19:04-07:00
[System]        FileCreateDate                  : 2019:03:30 09:48:02-07:00
[IFD0]          ModifyDate                      : 2019:03:30 09:48:01
[ExifIFD]       DateTimeOriginal                : 2019:03:30 09:48:01
[ExifIFD]       CreateDate                      : 2019:03:30 09:48:01
[ExifIFD]       SubSecTime                      : 20
[ExifIFD]       SubSecTimeOriginal              : 20
[ExifIFD]       SubSecTimeDigitized             : 20


If that's the case and the listed DateTimeOriginal or CreateDate is correct, you could run this much simpler command
exiftool '-FileModifyDate<DateTimeOriginal' /path/to/files/
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).