Command to Update DATE only, Keeping Original HH:MM:SS

Started by XionicFire, June 26, 2022, 09:30:04 PM

Previous topic - Next topic

XionicFire

Hi

Im trying to do a command where ExifTool updates the images various DATE fields but keeps the Original HH:MM:SS

So far I have been unable to make it work trying various methods, I am using windows and are not very familiar with regex, so I may be doing something wrong

Could someone tell me what part of this expression I am doing wrong:

C:\ExifTests>exiftool.exe -time:all=2022:06:24 ${DateTimeOriginal;s/.* //} -AllDates=2022:06:24 ${DateTimeOriginal;s/.* //} -FileModifyDate=2022:06:24 ${DateTimeOriginal;s/.* //} -FileCreateDate=2022:06:24 ${DateTimeOriginal;s/.* //} -IFD1:ModifyDate=2022:06:24 ${DateTimeOriginal;s/.* //} 1.jpg -overwrite_original -wm w

Returns:

Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in File:FileModifyDate (PrintConvInv)
Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in File:FileCreateDate (PrintConvInv)
Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in IFD1:ModifyDate (PrintConvInv)
Error: File not found - //}
Error: File not found - //}
Error: File not found - //}
Error: File not found - //}
Error: File not found - //}
    1 image files updated
    5 files weren't updated due to errors


Any help would be apreciated

XionicFire

sigh... it was one of those stupid syntax errors, i saw StarGeek's explanation of how the function worked here:

https://exiftool.org/forum/index.php?topic=7690.0

I did it exactly the same and it not work, so I went word by word on the command until I found the issue, you need to use < instead of = and added some quotes... I would have never figured it out, for those having this same problem the code is:

exiftool.exe "-time:all<2022:06:24 ${DateTimeOriginal;s/.* //}" "-AllDates<2022:06:24 ${DateTimeOriginal;s/.* //}" "-FileModifyDate<2022:06:24 ${DateTimeOriginal;s/.* //}" "-FileCreateDate<2022:06:24 ${DateTimeOriginal;s/.* //}" "-IFD1:ModifyDate<2022:06:24 ${DateTimeOriginal;s/.* //}"  XXXXXXX.jpg -overwrite_original -wm w


This works perfectly, I Hope this helps other people

XionicFire

if you want to use it in a batch file, here's how u do it:

@ECHO OFF
REM CORRECT DATE FORMAT FOR THIS BATCH FILE IS YEAR:MONTH:DAY HR(24):MN:SS
REM set date=%date% ${DateTimeOriginal;s/.* //} (use this if you want to use todays date)
set date=2022:06:24 ${DateTimeOriginal;s/.* //}
ECHO %date% (Sanity check)
for /r %%v in (*.jpg) do exiftool.exe "-time:all<%date% -AllDates<%date% -FileModifyDate<%date% -FileCreateDate<%date% -FileAccessDate<%date% -DateTimeOriginal<%date% -ModifyDate<%date% -CreateDate<%date% -SonyDateTime<%date% -SonyDateTime2<%date%" "%%v" -overwrite_original -wm w


This will replace the date on any files inside the batch files folder and any subfolders with the date you set on the variable

If you wish to keep it local (disable recursiveness) just remove the /r from the first part of the batch file and you are good to go

You may get an error saying certain file attributes can only be changed in MacOS, that's fine, it wont affect the operation and i left it on there because its a good way to know on what file is the batchfile currently on, to gauge how long is left before its done.

I hope this helps others.