changing dates, based on file name, simple formats

Started by bardobhb, December 09, 2023, 12:19:04 AM

Previous topic - Next topic

bardobhb

All the files that I would like to correct are in the format "YYYYMMDD other naming stuff". I would like the Created Date and Modified Date to match the file name, and I don't care about the exact time of day, they could just all be set to 1:00 PM.

I tried with a couple of MOV files and got this:

bardos-iMac:sort bardo$ exiftool "-AllDates<filename" *
Warning: [minor] The ExtractEmbedded option may find more tags in the media data - 20221126 -ekb- 2597.MOV
Warning: No writable tags set from 20221126 -ekb- 2597.MOV
Warning: [minor] The ExtractEmbedded option may find more tags in the media data - 20221204 -ekb- 2778.MOV
Warning: No writable tags set from 20221204 -ekb- 2778.MOV
    0 image files updated
    2 image files unchanged

I also tried with a couple of JPG files and got this:
bardos-iMac:sort bardo$ exiftool "-AllDates<filename" *
Warning: Hour '84' out of range 0..24 in ExifIFD:DateTimeOriginal (PrintConvInv) - 20221202 -o- 8406.jpg
Warning: No writable tags set from 20221202 -o- 8406.jpg
Warning: Hour '86' out of range 0..24 in ExifIFD:DateTimeOriginal (PrintConvInv) - 20221202 -o- 8636.jpg
Warning: No writable tags set from 20221202 -o- 8636.jpg
    0 image files updated
    2 image files unchanged

How would I modify the code to make these work? I'm on macOS Monterey 12.6.8

Thank you so much! I did try to find the answer in the forum already, so I apologize if this is a redundant newbie question, but the threads I was finding were beyond my very limited knowledge. The only things I've gotten to work on my own so far are "cd" and "exiftool "-FileModifyDate<DateTimeOriginal" *" (for the files that had a correct Content created date).

Thank you again!

StarGeek

Exiftool can set a time stamp from a filename, as shown in FAQ #5, but it needs a complete time stamp, date and time, which is 14 numbers in total.  The No writable tags errors you are getting are because there either isn't enough numbers, or there are numbers that are out of rage for a date/time.  The ExtractEmbedded option warnings can be ignored, they are only there to tell you that there may be more data in the file that isn't shown.

Since you have only the YearMonthDay, you need to include a dummy HourMinuteSecond value. So the date numbers need to be extracted and the rest of the filename removed.  Using your example filenames and setting to 1 pm (13:00:00), you would probably use
exiftool '-AllDates<${Filename;m/(\d{8})/;$_=$1} 13:00:00' /path/to/files/

There is a problem with video files though. The time stamps in videos are supposed to be set to UTC.  So if you set a time too early, for example midnight, then the file might show up under the previous day.  You can add the -api QuickTimeUTC option and exiftool will automatically write the UTC time using your computer's time zone.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype

bardobhb

Thank you so much! I was able to get it to work.

A note of curiosity, when I run exiftool '-AllDates<${Filename;m/(\d{8})/;$_=$1} 13:00:00' *, it only changes the "Content created" date, and it changes both the "Created" and "Modified" dates to the date/time of running the action. For some reason, my computer doesn't show the "Content created" date for MOV files, although it's apparently there and getting changed behind the scenes.

When I then do exiftool "-FileModifyDate<DateTimeOriginal" *, it changes both the "Created" and "Modified" dates to match the newly-revised "Content created" date.

StarGeek

Quote from: bardobhb on December 09, 2023, 05:31:46 PMit only changes the "Content created" date, and it changes both the "Created" and "Modified" dates to the date/time of running the action.

This is FAQ #3.  You need to figure out what the actual tags you want to change are.  From the sound of it, you wanted to change the file system time stamps.  Those would be FileCreateDate and FileModifyDate.

QuoteFor some reason, my computer doesn't show the "Content created" date for MOV files, although it's apparently there and getting changed behind the scenes.

Exiftool can't force your computer to display data.  That is programmed into the OS.
"It didn't work" isn't helpful. What was the exact command used and the output.
Read FAQ #3 and use that cmd
Please use the Code button for exiftool output

Please include your OS/Exiftool version/filetype