News:

2023-03-15 Major improvements to the new Geolocation feature

Main Menu

Set the file modification and creation date from EXIF info

Started by Joseph Allan, April 28, 2013, 10:37:25 PM

Previous topic - Next topic

Phil Harvey

Quote from: stefanoanzilotti on February 25, 2018, 04:09:57 PM
The command does not work if I manually delete the field for testing the command. I still do not figure out why that happened.

You don't get the same result when you try this on your system?:

$ exiftool -ver
10.80
$ exiftool a.jpg -datetimeoriginal=now
    1 image files updated
$ exiftool a.jpg -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -filename
    1 files failed condition
$ exiftool a.jpg -datetimeoriginal=
    1 image files updated
$ exiftool a.jpg -if '(not $datetimeoriginal or ($datetimeoriginal eq "0000:00:00 00:00:00"))' -filename
File Name                       : a.jpg
$
...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 ($).

stefanoanzilotti


I got the same result by your way, but If I delete the DataTimeOriginal field by Adobe Bridge the code does not work. That's really weird.

I spent a little time to set the Data File Created as the DataTimeOriginal, but I am still far to the solution. The code:

exiftool '-FileCreateDate<DateTimeOriginal' -overwrite_original_in_place -P -ext jpg -ext jpeg -ext gif -ext mp4 -ext mov .

gives me back this output:

Warning: This tag is Windows only in File:FileCreateDate (ValueConvInv) - ./Portugal00106.jpg
Warning: No writable tags set from ./Portugal00106.jpg
Warning: This tag is Windows only in File:FileCreateDate (ValueConvInv) - ./Portugal00105.jpg
Warning: No writable tags set from ./Portugal00105.jpg
    1 directories scanned
    0 image files updated
    2 image files unchanged


I understood that is not possible write over this field. Right?

Phil Harvey

On the Mac, the filesystem creation time is accessed through MDItemFSCreationDate.  FileCreateDate is Windows only.

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

stefanoanzilotti


Then, by the command:

exiftool '-MDItemFSCreationDate<DateTimeOriginal' -overwrite_original_in_place -P .

the output is:


exiftool '-MDItemFSCreationDate<DateTimeOriginal' -overwrite_original_in_place -P .
>


What should I do?



Phil Harvey

I think your quoting is funny.  Try using normal ASCII single quotes.

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

stefanoanzilotti


I agree with you that is funny!

Code:
exiftool '-MDItemFSCreationDate<DateTimeOriginal' -overwrite_original_in_place -P -ext jpg -ext jpeg -ext gif -ext mp4 -ext mov .

Output:

Warning: Error 256 running "setfile" to set MDItemFSCreationDate - ./b.jpg
Warning: Error 256 running "setfile" to set MDItemFSCreationDate - ./a.jpg
    1 directories scanned
    0 image files updated
    2 files weren't updated due to errors

Phil Harvey

What version of OS X are you running?  You need to have the "setfile" utility available to be able to write MDItemFSCreationDate.  I thought this was a standard OS X utility.

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

stefanoanzilotti


v10.13.3

Then I am going to find out a way to activate that! thank you man

Phil Harvey

#53
Ah.  It comes with the XCode developer tools (see here).  I hope you don't have to install the full XCode -- the download size is massive.

- Phil

Edit: Here is a post that shows how to install the tools without installing the full XCode for an older version of OS X.  Maybe it still applies.

Or in case you can run it directly, I have attached the setfile binary to this post.  This is from my 10.13.3 installation, so it should work as long as it doesn't rely on other developer libraries.

Edit2: Here are the libraries it depends on:

> otool -L /usr/bin/setfile
/usr/bin/setfile:
   /usr/lib/libxcselect.dylib (compatibility version 1.0.0, current version 1.0.0)
   /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)
...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 ($).

jmv

Quote from: Phil Harvey on May 01, 2013, 08:05:47 AM
Right.

- Phil

How do you run an equivalent command but not have exifTool execute the changes but rather get an output of what would be performed ?

Thanks

Phil Harvey

If you are writing FileName, then there is the TestName tag.  Also, you can use the -if statement in another command to see which files may be processed.  But there is no dry-run option if that is what you want.

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

jmv

Super! Thanks Phil !

And great work building that ExifTool :)