overwrite all dates and times with current date via command line

Started by datetime, February 18, 2021, 02:58:14 PM

Previous topic - Next topic

datetime

Hello

I struggle to find a solution and read many posts which i found via google, including on this forum.
Nothing helped so i signed up.

First: I want to set the CURRENT date & time via command line. I dont know how to get current time correctly.

Second: I want to overwrite many files with the current time, but only the tags it finds, which are very different! So i dont want to simply modify "DateTimeOriginal" or something, i want to also modify IF IT EXISTS IN THAT FILE things like SonyDateTime2 etc. etc. but i DONT want to add that time tag if it doesnt already exist!
also i dont want to remove those additional time tags UNLESS they have no valid time format (SubSecTimeOriginal              : 678480 for example) or if they simply cant be modified by exiftool.

Thank you SO MUCH in advance i'm banging my head on this for 4 hours now!

Phil Harvey

Quote from: datetime on February 18, 2021, 02:58:14 PM
First: I want to set the CURRENT date & time via command line. I dont know how to get current time correctly.

exiftool -now FILE

QuoteSecond: I want to overwrite many files with the current time, but only the tags it finds, which are very different! So i dont want to simply modify "DateTimeOriginal" or something, i want to also modify IF IT EXISTS IN THAT FILE things like SonyDateTime2 etc. etc. but i DONT want to add that time tag if it doesnt already exist!

exiftool -wm w -time:all=now DIR

Quotealso i dont want to remove those additional time tags UNLESS they have no valid time format (SubSecTimeOriginal              : 678480 for example) or if they simply cant be modified by exiftool.

I'm not sure what you want here.

- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

datetime

THANKS simpler than i thought

Encountered some other thing i dont get done by myself:
looking to overwrite it all with each files create date
-wm w -time:all<filecreatedate
-wm w "-time:all<filecreatedate"
-wm w -time:all=<filecreatedate
-wm w "-time:all=<filecreatedate"
-wm w -time:all=filecreatedate
-wm w "-time:all=filecreatedate"

didnt work

what shall i do, sir?

also i checked, and the "now" command didnt work for "samsung timestamp" i can only remove this with the trailer= function right?

StarGeek

See Common Mistake #5, 'exception to rule "b" '

This should work.  Swap the double quotes for single quotes if you're on Mac/Linux
-wm w "-time:all<$filecreatedate"
"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

datetime

THANK YOU, Works

used: exiftool -wm w "-time:all<$filecreatedate" -overwrite_original *.jpg


But on some files it modifies certain tags, but drops them on others completely, where they are just gone?! especially the SubSec stuff:

[Composite]     SubSecCreateDate                : 2021:02:19 08:41:18+01:00
[Composite]     SubSecDateTimeOriginal          : 2021:02:19 08:41:18+01:00
[Composite]     SubSecModifyDate                : 2021:02:19 08:41:18+01:00

so one some it works, on some it deletes.

if it helps:
got many errors like
Warning: Can only set MDItem tags on OS X
Warning: [minor] Unrecognized MakerNoteUnknown
Warning: [minor] Maker notes could not be parsed
Warning: Invalid EXIF text encoding for UserComment
Warning: [minor] Entries in IFD0 were out of sequence. Fixed.

Phil Harvey

The Now tag doesn't include subseconds.  You can use the -v2 option and write a tag by itself to see what is happening.  For example, SubSecDateTimeOriginal is a Composite tag that is based on the values of 3 EXIF tags:

> exiftool a.jpg -subsecdatetimeoriginal=now -v2
Writing Composite:SubSecDateTimeOriginal
Deleting ExifIFD:SubSecTimeOriginal
Writing ExifIFD:DateTimeOriginal
Writing ExifIFD:OffsetTimeOriginal
...


or just writing one of the EXIF SubSec tags directly:

> exiftool a.jpg -subsectimeoriginal=now -v2
Warning: Error converting value for ExifIFD:SubSecTimeOriginal (ValueConvInv)
Nothing to do.


- Phil
...where DIR is the name of a directory/folder containing the images.  On Mac/Linux/PowerShell, use single quotes (') instead of double quotes (") around arguments containing a dollar sign ($).

datetime

But how do i do it that it ONLY modifies the tag if it exists? I dont want to add it, if it does not exist. Thank you!

StarGeek

The -wm (writemode) option in the above commands does this.  The w argument to this option only allows for writing of existing tags.  It will not create new tags (g) or new groups (c).
"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