Hello all,
I decided to embark on the long journey of properly naming and tagging a decade worth of photos/videos. I have been trying to absorb as much as I could about photo/video workflow and utilization of ExifTool in combination with Hazel.
Devices
- Macbook Pro
- Hazel
- ExifTool
- Pics/Vids are on iPhone
I found this script from another forum online, it works great for photos. I have no idea what it does, but it works, especially because most apps that upload to the cloud screw up the Exif Data.
Date Fix & Rename
exiftool -P -d '%Y-%m-%d at %H-%M-%S' \
'-filename<${FileModifyDate;}%-c.%e' \
'-filename<${GPSDateTime;}%-c.%e' \
'-filename<${MediaCreateDate;}%-c.%e' \
'-filename<${ModifyDate;}%-c.%e' \
'-filename<${DateTimeOriginal;}%-c.%e' \
"$1"
Another script to add author and keyword
exiftool -author="mikey" -P -overwrite_original_in_place "$1"
exiftool -keywords+=iphone -P -overwrite_original_in_place "$1"
FinalScript with a title of FileName>FileModifyDate
exiftool "-FileName>FileModifyDate" -d "%Y:%m:%d %H:%M:%S" -overwrite_original_in_place "$1"
Now, I don't know what all these scripts do, because I am not a programmer. (trying to learn and read)
With my pictures, they worked great.
With my .mov files, I noticed the times were off by roughly 8 hours. (not sure)
So then, I made a separate rule in Hazel....operate the pictures with the same codes above, but make a separate rule for movies.
here is the following code
exiftool -P -d '%Y-%m-%d at %H-%M-%S' \
'-filename<${FileModifyDate;}%-c.%e' \
'-filename<${GPSDateTime;}%-c.%e' \
'-filename<${MediaCreateDate;}%-c.%e' \
'-filename<${CreationDate;}%-c.%e' \ (I changed this line to match the tag I saw from the data of the video)
'-filename<${DateTimeOriginal;}%-c.%e' \
"$1"
And then I followed the author, keyword, script, and then the final script from earlier.
Questions.
1. May someone please explain what this script does line by line?
2. What is the purpose of that 3rd script called Filename>FileModifyDate
3. Is what I did for the videos (and keeping everything else) correct? or am i creating chaos that I will regret?
Thank you!
Quote from: frmike on January 13, 2017, 07:00:13 PM
1. May someone please explain what this script does line by line?
You should take a look at the application documentation (https://exiftool.org/exiftool_pod.html). It explains everything in detail. Specifically, this command uses
-P to preserve the original file modification date (but this option does nothing because the file isn't actually being changed), and
-d to specify the date/time formatting for the date/time tags. Then each
-filename<... option is setting the file name from the specified date/time tag. If the date/time tag doesn't exist, then the option is ignored, and the last one of these with a valid date/time tag will override earlier ones.
Quote2. What is the purpose of that 3rd script called Filename>FileModifyDate
This sets the filesystem modification date/time back from the date/time in the file name.
Quote3. Is what I did for the videos (and keeping everything else) correct? or am i creating chaos that I will regret?
This should be fine for videos. You may want to add
-api quicktimeutc if the video times are wrong due to your time zone.
- Phil
Thank you Phil!
I will take a look at the documentation.
I took a closer look at the information generated from ExifTool for the .mov files and found the following.
Create Date : 2016:12:19 03:04:28
Modify Date : 2016:12:19 03:05:12
Track Create Date : 2016:12:19 03:04:28
Track Modify Date : 2016:12:19 03:05:12
Media Create Date : 2016:12:19 03:04:28
Media Modify Date : 2016:12:19 03:05:12
Creation Date : 2016:12:18 19:04:28-08:00 (as you mentioned in previous replies and topics that I searched, it seems that 8 hours gets tacked on from the creation date on the iPhone 7)
How can I add the -api quicktimeutc into my earlier script that I mentioned?
Right now, after a search, I found this..
I open Terminal and type
exiftool -CreateDate $1 DIR
and then after comparing dates
exiftool "-CreateDate-=0:0:0 8:0:0" -ext .mov -r -overwrite_original_in_place DIR
I still need to overwrite the filename to reflect the new CreateDate
Would this be okay? (But it's not using the -api?)
exiftool -P -d '%Y-%m-%d at %H-%M-%S' \
'-filename<${FileModifyDate;}%-c.%e' \
'-filename<${GPSDateTime;}%-c.%e' \
'-filename<${MediaCreateDate;}%-c.%e' \
'-filename<${CreationDate;}%-c.%e' \ (This is the tag from my iPhone)
'-filename<${DateTimeOriginal;}%-c.%e' \
"$1"
This is a tough one. Since we are talking movies from an iPhone here we need to make the following observations:
1. iPhones (correctly) record the various times as UTC so you'll definitely want to add the -api QuickTimeUTC option to your commands
2. The CreationDate is set by the iPhone and includes the timezone at the location you recorded the movie (this is very nice as it helps getting everything right!)
Conclusion: in this case, the CreationDate is actually the best source for the date and time you shot the movie. So you should really use the following command in this case (putting CreationDate as last one):
exiftool -api QuickTimeUTC -P -d '%Y-%m-%d at %H-%M-%S' \
'-filename<${FileModifyDate;}%-c.%e' \
'-filename<${GPSDateTime;}%-c.%e' \
'-filename<${MediaCreateDate;}%-c.%e' \
'-filename<${DateTimeOriginal;}%-c.%e' \
'-filename<${CreationDate;}%-c.%e' \
"$1"
Also: do NOT change the CreateDate as you did since then you are doubly compensating for UTC, use the -api QuickTimeUTC option instead.
A note on the GPSDateTime: that will give you the time of recording but than as your local time, not necessarily the local time where it was shot. Are you on a Mac/Linux or Windows? If on a Mac/Linux, you can temporarily change your local timezone by prefixing the exiftool command with e.g. TZ="Europe/Paris" to indicate the video was shot in Paris.
If you only/mostly shoot video with your iPhone, you may want to create an ExifTool_config file to always enable the QuickTimeUTC option.
# Set procession options
%Image::ExifTool::UserDefined::Options = (
# Quicktime Date/Times are in UTC
QuickTimeUTC => 1,
);
I try to do something similar (Win7 64 bit, latest Exitool Version = 10.40):
Copy the EXIF-Creation Time to the Creation Time (within a CR2 or JPG file / no .xmp), i.e. set Creation Time (for sorting in the file manager) to Creation time as stored in EXIF data. No Renaming.
I feel I am very near to my goal, but not quite.
I tried
exiftool -System:FileCreateDate=ExifIFD:DateTimeOriginal CascataToce42.CR2
but I get an error message:
"Warning: Invalid date/time (use YYYY:mm:dd HH:MM:SS[.ss][+/-HH:MM|Z]) in File:FileCreateDate (PrintConvInv)
Nothing to do."
(in this file - Date/Time Original: 2016:08:04 14:37:27
File Creation Date/Time: 2017:01:15 12:58:19+01:00)
It seems only the string '+01:00' is required, but I don't know how to do string operations; all I tried ('', +" ", &' ' ... do not work). I was unable to find instructions about concatenation.
You used the assignment operation (equal sign) but should have used the tag copy operation (less/greater than sign).
-System:FileCreateDate=ExifIFD:DateTimeOriginal tries to set the FileCreatedate to the text "ExifIFD:DateTimeOriginal", not the date held in the ExifIFD:DateTimeOriginal tag.
Try "-System:FileCreateDate<ExifIFD:DateTimeOriginal" instead. Quotes are necessary to avoid file redirection by the OS.
yesss
works perfectly !
thanks very much for the quick reply :-)
Thank you Hayo,
I followed the script that you mentioned and it works great for videos. I have set this script to be run inside of Hazel when processing videos.
However, I noticed that this rule cannot be applied to photos. The following was the initial rule for photos that I was using
exiftool -P -d '%Y-%m-%d at %H-%M-%S' \
'-filename<${FileModifyDate;}%-c.%e' \
'-filename<${GPSDateTime;}%-c.%e' \
'-filename<${MediaCreateDate;}%-c.%e' \
'-filename<${ModifyDate;}%-c.%e' \
'-filename<${DateTimeOriginal;}%-c.%e' \
"$1"
After I run that code for pictures, I run 3 more.
(This one to add author and keyword to my pictures)
exiftool -author="mikey" -P -overwrite_original_in_place "$1"
exiftool -keywords+=iphone -P -overwrite_original_in_place "$1"
and then I use this final code
exiftool "-FileName>FileModifyDate" -d "%Y:%m:%d %H:%M:%S" -overwrite_original_in_place "$1"
What I can't figure out after running these (just for pictures) I see the following. (screenshot attached)
I should mention the original name of the file is the following 2017-01-08_14-55-40_IMG_6708.JPG which gets renamed to (name - pixel height x pixel width.jpg (2017-01-08 at 14-55-40 - 3024 x 4032)
However, I can't figure out why the computer date of created/modified do not match the filename time stamp...
Hmm, I tried this myself and when I use you command on a file with the name 2017-01-08 at 14-55-40 - 3024 x 4032.JPG the command fails with the following warnings:
Warning: Error parsing time in File:FileModifyDate (PrintConvInv) - 2017-01-08 at 14-55-40 - 3024 x 4032.JPG
Warning: No writable tags set from 2017-01-08 at 14-55-40 - 3024 x 4032.JPG
But, that's easily explained because you have a -d option here (that you don't even need), without it it works fine and I get the correct dates (note you also don't need -overwrite_original_in_place since you're not changing the file content).
Try this: exiftool "-FileName>FileModifyDate" "$1"
Cheers,
Hayo
I took another approach.....and borrowed a script from another person and combined...
here is what I have that "I think" works so far. If another set of eyes can verify my process.
I am using Hazel on Mac with ExifTool
1) File gets uploaded from iPhone via PhotoSync App to Amazon Cloud Drive (mounted on mac with oDrive)
2) Original File Name is 2016-12-24_20-48-34_IMG_6660.mov
3) First Hazel Rule with ExifTool Embedded Script Kicks in (Thanks to Phil Harvey for correcting for me)
Shell is /bin/bash
exiftool -api QuickTimeUTC -P -d '%Y-%m-%d at %H-%M-%S' \
'-filename<${FileModifyDate;}%-c.%e' \
'-filename<${GPSDateTime;}%-c.%e' \
'-filename<${MediaCreateDate;}%-c.%e' \
'-filename<${DateTimeOriginal;}%-c.%e' \
'-filename<${CreationDate;}%-c.%e' \
"$1"
4) This takes the original file name (with correct timestamp) and corrects Finder (created, modified, and last opened)
5) This rule is run next after
exiftool "-FileName>FileModifyDate" -d "%Y:%m:%d %H:%M:%S" -overwrite_original_in_place "$1"
6) Final filename looks like 2016-12-24 at 20-48-34 - 1080 x 1920.mov
That takes care of my quicktime videos from Apple.
Now on to photos...I had difficulty in replicated this same process with Photos...I could not figure out how to change the 3 variables in Finder (created, modified, and last opened) to match the timestamp in the file name.
1) File gets uploaded from iPhone via PhotoSync App to Amazon Cloud Drive (mounted on mac with oDrive)
2) Original File Name is 2017-01-08_14-55-40_IMG_6708.jpg
3) First Hazel Rule with ExifTool Embedded Script Kicks in (Thanks to Federico on his blog)
Shell is usr/bin/php
<?phpdate_default_timezone_set("America/Los_Angeles");$date = exif_read_data($argv[1],"EXIF");$date = $date["DateTimeOriginal"];$time = date_parse_from_format("Y:m:d at H:i:s",$date);$time = mktime($time["hour"],$time["minute"],$time["second"],$time["month"],$time["day"],$time["year"]);touch($argv[1],$time,$time);?>
4) This takes the original file name (with correct timestamp) and corrects Finder modified, and last opened
but not created)
5) This rule is run next after
exiftool "-FileName>FileModifyDate" -d "%Y:%m:%d %H:%M:%S" -overwrite_original_in_place "$1"
6) Final filename looks like 2017-01-08_14-55-40_IMG_6708 - 3024 x 4032.jpg
I would like the final filename to be nicer looking (similar to the video) but I haven't figured that out. (I just want to add the words "at" in between YYYY-MM-DD at HH-MM-SS.
Let me know your thoughts!
Thank you Hayo!
I updated based on what you told me, oddly, I removed the -d, and then re-added it again. I am not seeing any errors in my Hazel log at all.
I also fixed up the other code based on your recommendation.
It now fully works for videos. File name with correct timestamp is viewed in Finder (created, modified, date opened)
For the photos, the file name with correct timestamp is also viewed in finder (modified, and date opened, no created date)
But I think this works, much better to where I was 24 hours ago ! Thank you!
Some further comments:
Step 2: Why do you use different approaches for MOV and JPG? The MOV solution should work for the JPG too (unless your images were taken somewhere that isn't your timezone, but that's a problem you will always have with the filemodify date, that's another reason why that is a really bad choice of information source).
Step 4: On a Mac (and Linux) there is no way to change the file create date. The only exception is that if the modify date is set before the create date, the create date is adjusted to match that (you can not change a file before it exists).
Step 5: remove the -d and -overwrite_original_inplace options. Note also that this step again overwrites the touch command you perform in step 3 for the JPGs.
Step 6: How come the filename is now as you say? The only place you set it is in step 3 (and then only for the mov files), but you do not add the size to the string so how did you get it there?
So here is what I am currently doing (that seems to work for photos and videos so far based on what you have said)
1) File name comes in from oDrive/Amazon Cloud via Photosync App with the following format, they all come as one big long list of files
2016-12-24_20-48-34_IMG_6660.mov
2016-12-24_20-48-34_IMG_6660.jpg
I then use a total of 3 Hazel Rules (still adding more)
Rule 1 - Date Fix&Rename for All Photos/Videos
If all of the following conditions are met...
If any of the following conditions are met...
Kind is image, Kind is Movie
Run Shell Script
exiftool -api QuickTimeUTC -P -d '%Y-%m-%d at %H-%M-%S' \
'-filename<${FileModifyDate;}%-c.%e' \
'-filename<${GPSDateTime;}%-c.%e' \
'-filename<${MediaCreateDate;}%-c.%e' \
'-filename<${DateTimeOriginal;}%-c.%e' \
'-filename<${CreationDate;}%-c.%e' \
"$1"
I then add a color label
and then the file is Renamed to name - pixel width x pixel height.extension
Hazel Rule 2
exiftool -author="mikey" -P -overwrite_original_in_place "$1"
exiftool -keywords+=iphone -P -overwrite_original_in_place "$1"
Hazel Rule 3
exiftool "-FileName>FileModifyDate" "$1"
Starting File Name 2016-12-24_20-48-34_IMG_6660.jpg
Ending File Name 2016-12-24 at 20-48-34 - 1080 x 1920.jpg
My ideal that I want but can't seem get the right combo would be...
2016-12-24 at 20-48-34_IMG_6660.jpg (I want to keep the IMG_numbering in case of bursts)
But I can't see where it got removed form. I keep going back and forth whether I really need to see pixel width/height in my pictures, I think the filename/number should take precedence.
If you want to retain the image number you need to adjust rule 1, that's where it gets stripped. Change the %-c.%e part to e.g. #${filename;s/.*(\d{4}\..*)/$1/;} (in place of the # you can use whatever you like as delimiter).
Hazel rule two can be merged into one line, in fact so can rule 3:
exiftool -author=mikey -keywords+=iphone "-FileName>FileModifyDate" -overwrite_original_in_place "$1"
Cheers,
Hayo
Thank you Hayo!
Sorry for my ignorance, but I am still learning a lot of this.
exiftool -api QuickTimeUTC -P -d '%Y-%m-%d at %H-%M-%S' \
'-filename<${FileModifyDate;}%-c.%e' \
'-filename<${GPSDateTime;}%-c.%e' \
'-filename<${MediaCreateDate;}%-c.%e' \
'-filename<${DateTimeOriginal;}%-c.%e' \
'-filename<${CreationDate;}%-c.%e' \
"$1"
On which line, would I do the change?
You'd need to change the %-c.%e on all lines (5 times).
Big thanks to Hayo!
Here is the script he helped me with getting to do things right.
exiftool -api QuickTimeUTC -P -d '%Y-%m-%d at %H-%M-%S' \
'-filename<${FileModifyDate;}$#{filename;s/.*(\d{4}\..*)/$1/;}' \
'-filename<${GPSDateTime;}$#{filename;s/.*(\d{4}\..*)/$1/;}' \
'-filename<${MediaCreateDate;}$#{filename;s/.*(\d{4}\..*)/$1/;}' \
'-filename<${DateTimeOriginal;}$#{filename;s/.*(\d{4}\..*)/$1/;}' \
'-filename<${CreationDate;}$#{filename;s/.*(\d{4}\..*)/$1/;}' \
"$1"
Works for photos and movies.
Beginning file name looks like this 2017-01-09_16-40-26_IMG_6714.jpg
Ending file name looks like this 2017-01-09_16-40-26_IMG_6714 - 3024 x 4032.jpg
Modified Date in Finder checks out to match the above timestamp
Last Opened Date in Finder checks out to match the above timestamp
The only possible change I would recommend (but it's more for visual aide) is to have the words "at" between the date and time.
2017-01-09 at 16-40-26_IMG_6714 - 3024 x 4032
But, I am content. :) Thank you everyone
OK, I'm stumped. What is the "#" symbol for in "$#{filename...", and why does it work? (As far as I know, that is an invalid syntax.)
- Phil
Quote from: Phil Harvey on January 16, 2017, 07:09:57 AM
OK, I'm stumped. What is the "#" symbol for in "$#{filename...", and why does it work? (As far as I know, that is an invalid syntax.
Oops, the
# is meant to go before the
$ (and can be replaced by anything you like as separator)
And actually looking at the output, it didn't work with the # at the wrong position; the filenames were NOT changed from their original (hence also the missing at in the date).
Yes, everything looks good now with the corrections!
Thank you so much!
Some other hint posted one year later.
See https://exiftool.org/forum/index.php?topic=9647.msg50095#msg50095 for details.
Quick excerpt:
With a custom config, you can use MyDate as date:
exiftool -config my.config ... -filename<MyDate
%Image::ExifTool::UserDefined = (
'Image::ExifTool::Composite' => {
MyDate => {
Desire => {
0 => 'DateTimeOriginal',
1 => 'CreateDate',
2 => 'FileModifyDate',
},
ValueConv => '$val[0] || $val[1] || $val[2]',
PrintConv => '$self->ConvertDateTime($val)',
},
},
);
1; #end