ExifTool Forum

ExifTool => Newbies => Topic started by: straughny5446 on November 04, 2017, 02:39:02 PM

Title: Set capture time from unix's inode birth time.
Post by: straughny5446 on November 04, 2017, 02:39:02 PM
I'm using After much digging around, I finally found the date/timestamp I'm after, via the unix 'stat' command...(sourcing the inode's birth time) which gave me a date that wasn't other visible via exiftool -time:all

e.g.:

$ exiftool -time:all -a -G0:1 -s IMG_0020.JPG
[File:System]   FileModifyDate                  : 2014:07:12 12:47:00-07:00
[File:System]   FileAccessDate                  : 2017:11:04 10:42:46-07:00
[File:System]   FileInodeChangeDate             : 2017:11:04 10:32:01-07:00
[EXIF:IFD0]     ModifyDate                      : 2014:07:12 13:47:00
[XMP:XMP-xmp]   ModifyDate                      : 2014:07:12 13:47:00-06:00
[ICC_Profile:ICC-header] ProfileDateTime        : 2003:07:01 00:00:00

$ stat -f %SB IMG_0020.JPG
Dec 29 21:02:00 2010


Excellent :) . So... that was the hard part.  But I'm a newbie to exiftool otherwise, and I can't seem to find a method to set the EXIF capture

$ exiftool "-datetimeoriginal<xxxxxx" ./IMG_0020.JPG

How can I get stat's date/timestamp into datetimeoriginal?   Is there an exiftool command line option? Or do I need some unix shell scripting?  (if so, happy to take advice here!)

Thanks, much appreciated!

$ sw_vers // ProductName:   Mac OS X // ProductVersion:   10.12.6 // BuildVersion:   16G29
$ exiftool -ver // 10.64
Title: Re: Set capture time from unix's inode birth time.
Post by: Phil Harvey on November 04, 2017, 05:07:38 PM
You could do this:

exiftool -datetimeoriginal=`stat -f %SB -t "%Y:%m:%d %H:%M:%S" FILE` FILE

I wasn't aware of this inode birth date/time -- it isn't available via the stat function of the standard Perl library that ExifTool uses.

- Phil
Title: Re: Set capture time from unix's inode birth time.
Post by: straughny5446 on November 04, 2017, 06:14:52 PM
Thanks Phil, much appreciated. It nearly works!


$ echo $SHELL
/bin/bash
$ stat -f %SB -t "%Y:%m:%d %H:%M:%S" IMG_0022.JPG
2010:12:29 21:04:11
$ exiftool -datetimeoriginal=`stat -f %SB -t "%Y:%m:%d %H:%M:%S" IMG_0022.JPG` IMG_0022.JPG
Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in ExifIFD:DateTimeOriginal (PrintConvInv)
Error: File not found - 21:04:11
    0 image files updated
    1 image files unchanged
    1 files weren't updated due to errors
$


Seems like I might need some added escape characters so exiftool doesn't see that 'space' between the date & time.

I've tried some variations around that stat command...to no avail.  Any ideas?

Yeah, this inode birth time took me a LONG time to find. It's visible if you "Command i" on a file in Mac's Finder.

Thanks again for your assistance.
Title: Re: Set capture time from unix's inode birth time.
Post by: Hayo Baan on November 04, 2017, 06:34:08 PM
Quote from: Phil Harvey on November 04, 2017, 05:07:38 PM
You could do this:

exiftool -datetimeoriginal=`stat -f %SB -t "%Y:%m:%d %H:%M:%S" FILE` FILE

I wasn't aware of this inode birth date/time -- it isn't available via the stat function of the standard Perl library that ExifTool uses.

- Phil

I actually mentioned the stat's birth time a long time ago to you ;) But since you implemented the mditem stuff (keep forgetting their exact names though), there is no need to go the stat route anymore. The createdate is available via the mdicreatedate (please correct the name, I'm sure I wrote it wrong though)
Title: Re: Set capture time from unix's inode birth time.
Post by: straughny5446 on November 05, 2017, 01:29:17 AM

I've fixed that last minor bug with the command, without needing escape characters.   This worked:

exiftool -datetimeoriginal=`stat -f %SB -t "%Y:%m:%d-%H:%M:%S" IMG_0022.JPG` -d "%Y:%m:%d-%H:%M:%S" IMG_0022.JPG

Thanks for your help.
Title: Re: Set capture time from unix's inode birth time.
Post by: Phil Harvey on November 05, 2017, 07:24:14 AM
Quote from: Hayo Baan on November 04, 2017, 06:34:08 PM
I actually mentioned the stat's birth time a long time ago to you ;) But since you implemented the mditem stuff (keep forgetting their exact names though), there is no need to go the stat route anymore. The createdate is available via the mdicreatedate (please correct the name, I'm sure I wrote it wrong though)

I had forgotten about this.  Thanks for reminding me.  So if the inode birth time is the same as the file creation date, you can use this command on the Mac:

exiftool "-datetimeoriginal<MDItemFSCreationDate" FILE

- Phil