Overwriting Date metafile in Images and Videos

Started by marchiados, February 13, 2024, 10:13:41 AM

Previous topic - Next topic

marchiados

Hello everyone!

I have thousands of photos and videos whose file name makes the date of the file explicit, but in the metadata the date is not present.

The format of my file names is "IMG-20220102-WA0050.jpg".
So, I used the regular expression
exiftool -overwrite_original -DateTimeOriginal='${Filename:0:4}-${Filename:5:2}-${Filename:8:2}' *.jpg

But i receive this "Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in ExifIFD:DateTimeOriginal (PrintConvInv)
Nothing to do."

I am new in this world, so I am sorry if I am asking you something really stupid, may someone help me?

Thank you  :D

greybeard

Try something like this:

exiftool '-DateTimeOriginal<${filename;s/IMG-(\d\d\d\d)(\d\d)(\d\d)-.*$/$1-$2-$3/}' -d '%Y-%m-%d' -ext jpg .

You might need to switch single quotes to double quotes under Windows

marchiados


StarGeek

"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

marchiados

Thank you so much!

What about if I want to do the same with videos with the same template? (VID-20200407-WA0065.mp4)

StarGeek

Same command would work, except you would probably want to add the -api QuickTimeUTC option, as video time stamps are supposed to be in UTC.

See this post for my standard copy/paste on videos and UTC.
"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