Exclude time from the commands -alldates / -filemodifydate / -filecreatedate

Started by vissrox3, December 02, 2022, 04:07:44 PM

Previous topic - Next topic

vissrox3

I want to fix the dates of photos received and sent on Whatsapp, many have the wrong date and in the gallery they go to the top. The problem is that the filename is: "IMG-20221112-WA0002" and using commands like "-alldates<filename" puts me the right date but the time "00:02" (in this case) I don't want it to put the time but only the date. Is this possible?

StarGeek

Technically possible, but not really advisable.  Nearly all programs expect there to be a date and a time.  Those that will read the date only will give the file a time of 00:00:00 anyway, so you might as well just include that.

You can force only a date with this command.  The last bit is '3spaces:2spaces:2spaces'  This sets blanks in the time related parts of the tag which is what the spec calls for.
exiftool "-alldates#<${filename;m/(\d{4})(\d\d)(\d\d)/;$_=$1.':'.$2.':'.$3.'   :  :  '}" /path/to/files/

The command for setting a time of midnight would be
exiftool "-AllDates<${Filename;m/(\d{8})/;$_=$1} 00:00:00}" /path/to/files/

The first command needs specific formatting due the forced write with the hashtag # shortcut for the -n (--printConv) option.  The second command doesn't need the formatting as exiftool will correctly parse the numbers.  See FAQ #5, paragraph starting "Having said this" for details.

For FileModifyDate/FileCreateDate, you cannot set those without a time as these are part of the underlying filesystem and not tags embedded in the file.  The file system won't allow for partial time stamps.
* 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).