Please help: changing CreateDate & ModifyDate in a PDF

Started by LisaMalloy128, January 14, 2024, 11:13:02 AM

Previous topic - Next topic

wywh

Quote from: konsti on November 01, 2024, 09:59:01 AMWarning: Error 512 running "/usr/bin/setfile" to set FileCreateDate - My.mkv
    1 image files updated

Any idea what could be causing this error? I have not had issues with past versions (and macOS) to be honest, cannot remember when this started.

I noticed that "Warning: Error 512 running "/usr/bin/setfile" to set FileCreateDate" after upgrading to macOS Sequoia 15 and Xcode 16. In earlier macOS Sonoma 14.7 and Xcode 15.3 that message does not occur.

But in my setup the output is still as expected also with macOS 15.0.1 and Xcode 16.

For example there is that warning when copying .xmp sidecars to .jpg. That warning could be fixed by editing time zone off from the .xmp sidecar. For example edit...

<photoshop:DateCreated>2000-01-01T12:00:00+02:00</photoshop:DateCreated>
...to:
<photoshop:DateCreated>2000-01-01T12:00:00</photoshop:DateCreated>

...then there is no such setfile warning. ...but then in my command is "Warning: Error converting value for ExifIFD:OffsetTimeOriginal (PrintConvInv)" because the time zone Offset is missing from the .xmp and I am trying to copy it...

- Matti

Phil Harvey

Ah ha!  So the problem could be that the new setfile doesn't like having a timezone added.  If true, this should produce an error code:

/usr/bin/setfile -d '01/02/2000 03:04:05+06:07' My.mkv
echo $?


If this does then I'll add a patch to remove the time zone.  (Note that this still returns 0 on my Mojave system.)

- 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 ($).

wywh

Quote from: Phil Harvey on November 01, 2024, 01:37:06 PMthe problem could be that the new setfile doesn't like having a timezone added

Yes, that seems to be the case:

/usr/bin/setfile -d '01/02/2000 03:04:05+06:07' a.jpg
echo $?
ERROR: invalid time (expected hh:mm[:ss] [AM|PM])
2

/usr/bin/setfile -d '01/02/2000 03:04:05' a.jpg     
echo $?
0

For some reason some commands succeed to change FileCreateDate while some commands fail if trying to copy a date with a time zone.

- Matti

konsti

Perhaps the Sonoma 14.7.1 update follows the new Sequoia mentality and the SetFile date formatting but it is idiotic to remove support for timezones!

Again on my "latest" Xcode command-line tools, the format in SetFile -h reports:

% setfile -h

Usage: SetFile [option...] file...
    -a attributes     # attributes (lowercase = 0, uppercase = 1)*
    -c creator        # file creator
    -d date           # creation date (mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]])*
    -m date           # modification date (mm/dd/[yy]yy [hh:mm[:ss] [AM | PM]])*
    -P                # perform action on symlink instead of following it
    -t type           # file type
[...]

...without any mention to timezone indeed... so I guess we will have to deal with the computer's own timezone %z Phil?

That is what I had added in my .zprofile alias for MOV files, after searching the forum here sometime ago:

alias exifmov="exiftool -v -m '-FileCreateDate<("$"CreationDate+"$"(date+'%z'))' '-FileModifyDate<("$"CreationDate+"$"(date+'%z'))' -ext mov -ext MOV ."

konsti

#19
For the record, doubt that a timezone of +06:07 exists so I tried with +06:00 just to be on the safe side, and still fails.

% /usr/bin/setfile -d '01/02/2000 03:04:05+06:00' report.pdf
ERROR: invalid time (expected hh:mm[:ss] [AM|PM])
% echo $?                                                 
2

StarGeek

Quote from: konsti on November 01, 2024, 05:23:56 PMFor the record, doubt that a timezone of +06:07 exists

But time zones of xx:30 (India for example) and xx:45 (Nepal) do exist, so it would have to be able to handle those at least.
"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

konsti

Indeed, but was just checking if it was hard-coded in SetFile command, StarGeek. You never ever know..

wywh

Quote from: konsti on November 01, 2024, 03:34:25 PMPerhaps the Sonoma 14.7.1 update follows the new Sequoia mentality and the SetFile date formatting but it is idiotic to remove support for timezones!

On the other hand file dates are UTC so I guess they do not use time zones anyway?

But currently the following command fails to update FileCreateDate because it tries to copy time zone:

exiftool -a -G1 -s -api QuickTimeUTC=1 -FileCreateDate -FileModifyDate -CreateDate -CreationDate movie.mp4
[MacOS]         FileCreateDate                  : 1999:06:01 12:00:00+03:00
[System]        FileModifyDate                  : 1999:06:01 12:00:00+03:00
[QuickTime]     CreateDate                      : 2024:06:01 12:00:00+03:00
[Keys]          CreationDate                    : 2024:06:01 12:00:00+03:00

exiftool -overwrite_original -api QuickTimeUTC=1 '-FileCreateDate<CreationDate' '-FileModifyDate<CreationDate' movie.mp4                                                           
Warning: Error 512 running "/usr/bin/setfile" to set FileCreateDate - movie.mp4
    1 image files updated

exiftool -a -G1 -s -api QuickTimeUTC=1 -FileCreateDate -FileModifyDate -CreateDate -CreationDate movie.mp4
[MacOS]         FileCreateDate                  : 1999:06:01 12:00:00+03:00
[System]        FileModifyDate                  : 2024:06:01 12:00:00+03:00
[QuickTime]     CreateDate                      : 2024:06:01 12:00:00+03:00
[Keys]          CreationDate                    : 2024:06:01 12:00:00+03:00

FWIW FileCreateDate can follow FileModifyDate backwards in time which obviously explains why despite the error the same command works here as expected:

exiftool -a -G1 -s -api QuickTimeUTC=1 -FileCreateDate -FileModifyDate -CreateDate -CreationDate movie.mp4
[MacOS]         FileCreateDate                  : 2024:06:01 12:00:00+03:00
[System]        FileModifyDate                  : 2024:06:01 12:00:00+03:00
[QuickTime]     CreateDate                      : 1999:06:01 12:00:00+03:00
[Keys]          CreationDate                    : 1999:06:01 12:00:00+03:00

exiftool -overwrite_original -api QuickTimeUTC=1 '-FileCreateDate<CreationDate' '-FileModifyDate<CreationDate' movie.mp4
Warning: Error 512 running "/usr/bin/setfile" to set FileCreateDate - movie.mp4
    1 image files updated

exiftool -a -G1 -s -api QuickTimeUTC=1 -FileCreateDate -FileModifyDate -CreateDate -CreationDate movie.mp4
[MacOS]         FileCreateDate                  : 1999:06:01 12:00:00+03:00
[System]        FileModifyDate                  : 1999:06:01 12:00:00+03:00
[QuickTime]     CreateDate                      : 1999:06:01 12:00:00+03:00
[Keys]          CreationDate                    : 1999:06:01 12:00:00+03:00

FileCreateDate seems to work with the following time zone related commands:

exiftool -overwrite_original -api QuickTimeUTC=1 -api TimeZone=America/New_York '-QuickTime:Time:All=2024:06:01 12:00:00' '-FileCreateDate=2024:06:01 12:00:00' '-FileModifyDate=2024:06:01 12:00:00' movie.mp4
    1 image files updated

exiftool -a -G1 -s -api QuickTimeUTC=1 -api TimeZone=America/New_York -FileCreateDate -FileModifyDate -CreateDate -CreationDate movie.mp4   
[MacOS]         FileCreateDate                  : 2024:06:01 12:00:00-04:00
[System]        FileModifyDate                  : 2024:06:01 12:00:00-04:00
[QuickTime]     CreateDate                      : 2024:06:01 12:00:00-04:00
[Keys]          CreationDate                    : 2024:06:01 12:00:00-04:00

exiftool -overwrite_original -api QuickTimeUTC=1 -api TimeZone=America/Los_Angeles '-QuickTime:Time:All=2024:06:01 12:00:00' '-FileCreateDate=2024:06:01 12:00:00' '-FileModifyDate=2024:06:01 12:00:00' movie.mp4
    1 image files updated

exiftool -a -G1 -s -api QuickTimeUTC=1 -api TimeZone=America/Los_Angeles -FileCreateDate -FileModifyDate -CreateDate -CreationDate movie.mp4
[MacOS]         FileCreateDate                  : 2024:06:01 12:00:00-07:00
[System]        FileModifyDate                  : 2024:06:01 12:00:00-07:00
[QuickTime]     CreateDate                      : 2024:06:01 12:00:00-07:00
[Keys]          CreationDate                    : 2024:06:01 12:00:00-07:00

- Matti

konsti

Thanks for the analysis, Matti

So Phil, I guess that the next ExifTool for Mac (whenever that is) should try getting/reading the local timezone of the user when using "SetFile" on any file, I guess?

Unless explicitly defined with e.g. -api TimeZone=Europe/Paris or like Matti's -api TimeZone=America/New_York ?

Phil Harvey

Great, thanks.  All I need to do is remove the time zone before the call to setfile, and all should be good.  I'm already converting to local time, which is what setfile expects.  This will be fixed in 13.02.

- 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 ($).

konsti

#25
Thank you, Phil !

Please in the on-line manual or --help notes, do put a mention of this change for people needing to set a different timezone than their own computers (when needed) as I have never done this consciously outside the scope of adding e.g. +01:00 or +03:00 (which will now be discarded in a next ExifTool MacOS version) and I only discovered very recently this -api TimeZone=ΧΧΧ thing that other users mentioned (incl. QuickTimeUTC etc.)

Many thanks to you and everyone, I guess this closes the "error 512" talk from my side.

Phil Harvey

I'm not sure how to document this.  It isn't specific to FileCreateDate since any date/time stored as UTC will behave this way.  And the behaviour for FileCreateDate will be the same as it has been for MacOS pre-Sequoia.

- 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 ($).

wywh

The change in setfile happened after Xcode 16.0. I wonder if Apple did this intentionally or if it reverts this in an update. Previously I have not paid much attention to the time zones in file dates because they behaved as expected anyway.

With the old Sonoma 14.6.1 and Command Line Tools for Xcode 15.3 setting FileCreatDate with time zone succeeds:

exiftool -a -G1 -s -FileCreateDate -FileModifyDate a.jpg 
[MacOS]         FileCreateDate                  : 1988:06:01 12:00:00+03:00
[System]        FileModifyDate                  : 1988:06:01 12:00:00+03:00

exiftool -FileCreateDate='2001:06:01 12:00:00-07:00' -FileModifyDate='2001:06:01 12:00:00-07:00' a.jpg
    1 image files updated

exiftool -a -G1 -s -FileCreateDate -FileModifyDate a.jpg                                             
[MacOS]         FileCreateDate                  : 2001:06:01 22:00:00+03:00
[System]        FileModifyDate                  : 2001:06:01 22:00:00+03:00

After updating to Command Line Tools for Xcode 16.0 or 16.1 setting FileCreateDate fails:

exiftool -a -G1 -s -FileCreateDate -FileModifyDate a.jpg
[MacOS]         FileCreateDate                  : 1988:06:01 12:00:00+03:00
[System]        FileModifyDate                  : 1988:06:01 12:00:00+03:00

exiftool -FileCreateDate='2001:06:01 12:00:00-07:00' -FileModifyDate='2001:06:01 12:00:00-07:00' a.jpg
Warning: Error 512 running "/usr/bin/setfile" to set FileCreateDate - a.jpg
    1 image files updated

exiftool -a -G1 -s -FileCreateDate -FileModifyDate a.jpg                                             
[MacOS]         FileCreateDate                  : 1988:06:01 12:00:00+03:00
[System]        FileModifyDate                  : 2001:06:01 22:00:00+03:00

Without time zone in the command and with some manual calculations it succeeds the same was as in the old Xcode.

Local time 12:00 + computer +03:00 - -07:00 = 22:00 (1st June DST was ON in some parts of the world...):

exiftool -a -G1 -s -FileCreateDate -FileModifyDate a.jpg
[MacOS]         FileCreateDate                  : 1988:06:01 12:00:00+03:00
[System]        FileModifyDate                  : 1988:06:01 12:00:00+03:00

exiftool -FileCreateDate='2001:06:01 22:00:00' -FileModifyDate='2001:06:01 22:00:00' a.jpg
    1 image files updated

exiftool -a -G1 -s -FileCreateDate -FileModifyDate a.jpg                                 
[MacOS]         FileCreateDate                  : 2001:06:01 22:00:00+03:00
[System]        FileModifyDate                  : 2001:06:01 22:00:00+03:00

- Matti

wywh

"Nov. 5, 2024 - Version 13.02: Fixed problem setting FileCreateDate on MacOS Sequoia if the date/time contains a time zone"

Thanks, now commands using setfile work as usual also with Command Line Tools for Xcode 16.0 and later.

exiftool -a -G1 -s -FileCreateDate -FileModifyDate a.jpg
[MacOS]         FileCreateDate                  : 1988:06:01 12:00:00+03:00
[System]        FileModifyDate                  : 1988:06:01 12:00:00+03:00

exiftool -FileCreateDate='2001:06:01 12:00:00-07:00' -FileModifyDate='2001:06:01 12:00:00-07:00' a.jpg
    1 image files updated

exiftool -a -G1 -s -FileCreateDate -FileModifyDate a.jpg                                             
[MacOS]         FileCreateDate                  : 2001:06:01 22:00:00+03:00
[System]        FileModifyDate                  : 2001:06:01 22:00:00+03:00

exiftool -FileCreateDate='2001:06:01 12:00:00' -FileModifyDate='2001:06:01 12:00:00' a.jpg     
    1 image files updated

exiftool -a -G1 -s -FileCreateDate -FileModifyDate a.jpg                                 
[MacOS]         FileCreateDate                  : 2001:06:01 12:00:00+03:00
[System]        FileModifyDate                  : 2001:06:01 12:00:00+03:00

- Matti

Phil Harvey

...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 ($).