datetimeoriginal - batch edit using Exiftool for macOS

Started by prettypixel, March 29, 2018, 08:12:59 AM

Previous topic - Next topic

prettypixel

I have been using the following command to edit the datetimeoriginal tag:

exiftool '-datetimeoriginal=2018:02:26 12:00:00' apple.jpg

I would now like to be able to batch edit this tag of all files in a given directory. I would like to keep the same date for all files, but if possible move the time on a minute for each file in the directory. Can this be done? If so, what command do I need to run?

Thank you in advance.

Phil Harvey

This can be done in 2 steps.

1. exiftool "-datetimeoriginal=2018:02:26 12:00:00" DIR

2. exiftool '-datetimeoriginal+<0:$filesequence' DIR

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

prettypixel

#2
Phil - Many thanks  :)

UPDATE: I ran the commands to batch edit all files in one directory. I just had one issue, the directory contains both .jpg and .png files. The .jpg files now appear in the macOS Photos 'Moments' timeline showing the correct date and time. However, the .png files display the incorrect date and time in the app.

I have viewed the .png files metadata using Exiftool, and the datetimeoriginal tags are correct. I would like to understand what the issue is with the .png files not displaying correctly in the macOS Photos app.

Many thanks.

Phil Harvey

For PNG you should probably write a native PNG tag.  I don't know what metadata Photos looks for, but you could try writing all available PNG date/time tags with different values to see which one takes:

CreateDate
ModifyDate
ModDate
CreationTime

Report back here if you can determine which one to use.

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

prettypixel

Many thanks Phil. I followed your advice:

1. Removal of all metadata from PNGs
2. Experimented by the following tags, with different values:
    * CreateDate
    * ModifyDate
    * ModDate
    * CreationTime
3. Imported the PNGs to macOS Photos app. Date/time information still incorrect on the 'Moments' timeline view. Then, after comparing the macOS Photos date/time information and Exiftool metadata retrieval for each PNG, I realised that macOS Photos must use either:
    * File Modification Date/Time tag
    * File Access Date/Time tag
    * File Incode Change Date/Time tag

I know this, because the date/time values of the three tags as shown by Exiftool, were the same in the macOS Photos 'Moments' timeline.

So, I started over:

1. Removal of all existing metadata from all files, JPG and PNG
2. GPS tags: exiftool -exif:gpslatitude="53.319507" -exif:gpslatituderef=N -exif:gpslongitude="-0.666974" -exif:gpslongituderef=W DIR
3. datetimeoriginal tag: exiftool '-datetimeoriginal=2018:01:01 12:00:00' DIR
4. One minute increments to datetimeoriginal tag: exiftool '-datetimeoriginal+<0:$filesequence' DIR
5. PNG only: filemodifydate tag: making sure this tag contained exactly the same values as the datetimeoriginal tag: exiftool '-filemodifydate=2018:01:01 12:45:00' filename.png
6. Import all images to macOS Photos app
7. All images, JPG and PNG now display the correct date/time information in the app

Does this sound like a reasonable workflow? Many thanks again.

Phil Harvey

Sure, sounds good, except that I would write PNG:CreateDate to PNG's instead of EXIF:DateTimeOriginal if you want to be as compatible as possible with other apps (since basically nothing but ExifTool will support EXIF in PNG images -- this was a fairly recent addition to the specification).  But since you are writing EXIF GPS tags also, you might as well continue to write EXIF:DateTimeOriginal, but maybe just add PNG:CreateDate to the command to write both if the file is PNG.

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

prettypixel

Hi Phil

Thank you for the advice.

Further to my previous reply - where I detailed my workflow, I found that, when I uploaded my PNG's to macOS Photos app and Google Photos, the GPS tags were not present. So, I decided to start over and convert PNG's to JPG's, then add date/time and GPS tags using Exiftool, and import to macOS Photos and Google Photos. All good.

Following your suggestion, I added the CreateDate tag to a PNG file to test out the results. Unfortunately, when the file was imported to macOS Photos and Google Photos, this info was not present and the date/time was incorrect.

It would seem that JPG files are the best file format to use, if GPS, date/time metadata, etc is important when using apps such as macOS Photos and Google Photos?

Thanks again  :)

Phil Harvey

Yes.  Unfortunately PNG metadata support by other applications is very poor.

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

Alan Clifford

It's probably too soon to change to HEIC format but I've read that Google Photos supports it as well as MacOS on High Sierra.

Phil Harvey

I would not recommend HEIC.  This is a very complex format that will take some time before it is supported by a wide range of applications (if ever).

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

uerceg

Quote from: Phil Harvey on March 29, 2018, 08:45:58 AMThis can be done in 2 steps.

1. exiftool "-datetimeoriginal=2018:02:26 12:00:00" DIR

2. exiftool '-datetimeoriginal+<0:$filesequence' DIR

- Phil

Thank you for the answer, worked like a charm (mostly). In my directory, I seem to have JPG files which were stripped from majority of the metadata. I have these files named in a way that if they are sorted by name, that order corresponds to the order of when images were taken. When I apply commands from quoted section, I do see shifts in creation times, but applied in pretty random order. I have two questions:

1. Is it possible to make creation time shifts to obey the ordering by name inside of the directory in some way (or to achieve this ordered shift in any other way)?
2. How would the syntax for 1 second shift look like?

Many thanks in advance.

Cheers
Ugi

Phil Harvey

Hi Ugi,

Quote from: uerceg on September 19, 2022, 07:17:37 PM1. Is it possible to make creation time shifts to obey the ordering by name inside of the directory in some way (or to achieve this ordered shift in any other way)?

Yes.  Add -fileorder filename to the command.

Quote2. How would the syntax for 1 second shift look like?

exiftool -fileorder filename '-datetimeoriginal+<0:0:$filesequence' DIR

- 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: uerceg on September 19, 2022, 07:17:37 PMobey the ordering by name inside of the directory

APFS filesystem (not the old Mac OS Extended) seems to offer files in some random order for processing. To set the order based on filename add this to the command:

-fileOrder FileName
- Matti

uerceg

No words to express my gratitude for these answers, it worked like a charm. Thank you! :flag-ca: