Write metadata creation data from filename?

Started by kas_lar, April 05, 2023, 03:37:45 PM

Previous topic - Next topic

kas_lar

Hi everyone.
I would be grateful for a few helping minutes of your time. Exiftool is quite powerful but a bit difficult to understand and use.

I have 4391 jpg pictures in a single folder.
Every picture is named correct by their created date:
2014_09_10_1.jpg
2014_09_10_2.jpg
2014_09_10_3.jpg

And
2015_08_02_1.jpg

And so on.

I also have 996 mp4 movies in a single folder named like the pictures above.

Every single files metadata creation data has been changed to 25 feb 2023 where I extracted the files from Tiny Beans (a children's photobook app)

I'd like to import the pictures and the movies into my library which reads metadata and places them in a timeline.

I'm using Mac osx and the app is working fine in terminal.

The files are located in :
users/download/pictures
And
users/download/movies


What kind of command line would you advise me to use?
Best regards from Denmark :D

Phil Harvey

The last number in the file name introduces a complication because it isn't related to the time.  You'll have use an advanced formatting expression to remove the last number from the file name, then add a fake time (ie. "00:00:00").  Also, you'll have to determine what date/time tag(s) you want to write.  Here is a command to set the filesystem modification date/time (FileModifyDate) from the FileName for all files in directory DIR:

exiftool '-filemodifydate<${filename;s/_\d+\..*//} 00:00:00' DIR

You may want to set CreateDate as well, or instead of FileModifyDate as above.  What you want to set depends on what information the MacOS software uses.

Use this command to see all date/time information available in a file:

exiftool -a -G1 -s -time:all FILE

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

StarGeek

First thing is to figure out which date/time tag you are actually trying to change.  You say "creation date" but I highly doubt you mean the CreationDate tag.  So figuring out exactly what tag needs changing is important.  Also, you might already have the correct time embedded in the file and in that case you don't want to overwrite it.

Run this command on some of your files
exiftool -time:all -G1 -a -s /path/to/files/

This will show you all the date time tags in the file.

I believe the tags you actually want to write are the file system tags, which would be FileModifyDate and FileCreateDate.  If the file already contains the correct date, hopefully in a tag such as CreateDate or DateTimeOriginal, then all you have to do is copy that tag into the file system tags.  Something like
exiftool "-FileCreateDate<CreateDate" "-FileModifyDate<CreateDate" /path/to/files/

For videos, things can get more complicated.  According to the specs, the time stamps embedded in the file are supposed to be set to UTC, but not all cameras write it properly.  That's usually not a problem these days with camera phones, but it still needs to be checked.  If the video time stamp is correctly set to UTC, then you can add the -api QuickTimeUTC option to the command and exiftool will adjust the time to the local time zone automatically.

If none of the above applies and the only data is the date in the filename, then that gets more complicated.  Post back if that's the case.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

kas_lar

#3
Hi and thanks for helping me out. A real newb :o

Good news!

I used:
exiftool -time:all -G1 -a -s /paths......

And the creation date is actually correct on the all the photos. Nice!
I don't know how I've come to the conclusion that the photos were wrong.
Let's focus on the movies. They're a a bit of a mess:

Here a movie from 2016:

/Downloads/movies/2016_02_09_2.mp4
[System]        FileModifyDate                  : 2023:02:26 08:37:16+01:00
[System]        FileAccessDate                  : 2023:02:26 08:37:16+01:00
[System]        FileInodeChangeDate            : 2023:04:05 21:28:48+02:00
[QuickTime]    CreateDate                      : 0000:00:00 00:00:00
[QuickTime]    ModifyDate                      : 0000:00:00 00:00:00
[Track1]        TrackCreateDate                : 0000:00:00 00:00:00
[Track1]        TrackModifyDate                : 0000:00:00 00:00:00
[Track1]        MediaCreateDate                : 0000:00:00 00:00:00
[Track1]        MediaModifyDate                : 0000:00:00 00:00:00
[Track2]        TrackCreateDate                : 0000:00:00 00:00:00
[Track2]        TrackModifyDate                : 0000:00:00 00:00:00
[Track2]        MediaCreateDate                : 0000:00:00 00:00:00
[Track2]        MediaModifyDate                : 0000:00:00 00:00:00


It's the same on all the 996 movies...
By the way - I'm importing all media into a Synology photos app.

Is there a clever way to use the filename data and convert it into  "create date"?

Phil Harvey

Quote from: kas_lar on April 07, 2023, 06:35:18 AMIs there a clever way to use the filename data and convert it into  "create date"?

Did you read my post above?

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

StarGeek

As Phil says, his post above gives the correct command.  All you would do is change FileModifyDate into CreateDate.

Though, depending upon your time zone, I might not use 00:00:00 as the time because of what I mentioned above about setting it to UTC.  If you're in a Western time zone, then the file would show up on the day before.

I would probably use noon UTC, e.g. 12:00:00. That will put the file on the correct date in nearly all cases.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).