ExifTool Forum

ExifTool => The "exiftool" Application => Topic started by: marchiados on February 13, 2024, 10:13:41 AM

Title: Overwriting Date metafile in Images and Videos
Post by: marchiados on February 13, 2024, 10:13:41 AM
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
Title: Re: Overwriting Date metafile in Images and Videos
Post by: greybeard on February 13, 2024, 10:42:17 AM
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
Title: Re: Overwriting Date metafile in Images and Videos
Post by: marchiados on February 13, 2024, 10:58:21 AM
It worked, thank you so much!!!  ;D  ;D  ;D
Title: Re: Overwriting Date metafile in Images and Videos
Post by: StarGeek on February 13, 2024, 11:38:16 AM
Previous post (https://exiftool.org/forum/index.php?topic=14262.msg77199#msg77199) for dealing with What's App images.
Title: Re: Overwriting Date metafile in Images and Videos
Post by: marchiados on February 17, 2024, 07:39:30 PM
Thank you so much!

What about if I want to do the same with videos with the same template? (VID-20200407-WA0065.mp4)
Title: Re: Overwriting Date metafile in Images and Videos
Post by: StarGeek on February 19, 2024, 08:21:26 AM
Same command would work, except you would probably want to add the -api QuickTimeUTC option (https://exiftool.org/ExifTool.html#QuickTimeUTC), as video time stamps are supposed to be in UTC.

See this post (https://exiftool.org/forum/index.php?topic=15650.msg84143#msg84143) for my standard copy/paste on videos and UTC.