Cannot set date for Whatsapp files

Started by warrencalvert, August 12, 2023, 06:50:14 AM

Previous topic - Next topic

warrencalvert

Hi

I have a folder full of whatsapp images with incorrect metadata date/time.  The filename is in the format IMG_20210628-WA0074.JPG

I've tried the commands below, on a single file initially, to set the date from the filename but none of them work.


1st Attempt:
C:\exiftool\exiftool.exe "-datetimeoriginal<filename"  -overwrite_original_in_place img-20210628-wa0074.*
Warning: Minutes '74' out of range 0..59 in ExifIFD:DateTimeOriginal (PrintConvInv) - IMG-20210628-WA0074.jpg
Warning: No writable tags set from IMG-20210628-WA0074.jpg
Warning: Minutes '74' out of range 0..59 in ExifIFD:DateTimeOriginal (PrintConvInv) - IMG-20210628-WA0074.xmp
Warning: No writable tags set from IMG-20210628-WA0074.xmp


2nd Attempt:
C:\exiftool\exiftool.exe "-datetimeoriginal<${filename;$_=substr($_,0,13)}"  -overwrite_original_in_place img-20210628-wa0074.*
Warning: No writable tags set from IMG-20210628-WA0074.jpg
Warning: No writable tags set from IMG-20210628-WA0074.xmp
    0 image files updated
    2 image files unchanged


3rd Attempt
C:\exiftool\exiftool.exe "-alldates<${filename;$_=substr($_,0,13)} 00:00"  -overwrite_original_in_place img-20210628-wa0074.*
Warning: No writable tags set from IMG-20210628-WA0074.jpg
Warning: Invalid tag name '00:00'. Use '=' not '<' to assign a tag value - IMG-20210628-WA0074.jpg
Warning: No writable tags set from IMG-20210628-WA0074.xmp
Warning: Invalid tag name '00:00'. Use '=' not '<' to assign a tag value - IMG-20210628-WA0074.xmp
    0 image files updated
    2 image files unchanged

4th Attempt
C:\exiftool\exiftool.exe "-alldates=${filename;$_=substr($_,0,13)} 00:00"  -overwrite_original_in_place img-20210628-wa0074.*
Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in IFD0:ModifyDate (PrintConvInv)

Please can you advise how I can achieve this, and set AllDates if possible.

Thanks,
Warren.

StarGeek

The tags covered in the AllDates shortcut require a complete date and time, 14 numbers in total.  WhatsApp filenames only contain the YearMonthDate, but no time component.  You need to add a placeholder time.

See this thread for an example command.
"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

warrencalvert

Thanks for the suggestion.  I tried that but cant get it to work.
I tried the command below, as per the thread, but it returns an error.


c:\exiftool\exiftool -if "$filename=~/^IMG-\d{8}-WA\d{4}\.\w*/" "-alldates<${filename;/(\d{8})/ and $_=$1} 00:00:00" -overwrite_original -v -r -i * -ext JPG -fast2 .

At line:1 char:92
+ ... name=~/^IMG-\d{8}-WA\d{4}\.\w*/" "-alldates<${filename;/(\d{8})/ and  ...
+                                                                 ~
Use `{ instead of { in variable names.
    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : OpenBraceNeedsToBeBackTickedInVariableName


I tried replacing {8} with '{8} as it suggested but it still returns the same error

Any ideas what's wrong?
Thanks

StarGeek

Use CMD, not PowerShell.

PS has a lot of idiosyncrasies that don't work well with some very basic exiftool commands, as well as corrupting binary data when redirecting or piping.  For example, when extracting a preview image from a file or using this example with cURL to read data from a image on the web.
"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

warrencalvert

Hi StarGeek

Thanks for spotting that.  I'd forgotten exiftool doesnt work well in powershell.

Its working now.

Thanks,
Warren.

aperturemode

How did you save these WhatsApp images? When I export directly from the app, it includes both date and time, however only in the filename. But at least it contains both. It seems you only have the date and not the time?