Hello,
Every now and then I need to change the ''Modify Date'' into the ''Original Date'' of some of my photos. I discovered this fantastic Exiftool which helps me a lot.
I get it to work via Terminal, using the code:
exiftool "-FileModifyDate<DateTimeOriginal"
However, to make my life easier, I would like to automate this task via Automator, using a Shell Script.
I am new to coding / scripting, and I have spent multiple hours trying to make it work.
After multiple attempts I thought I could use some help.
This is what I have so far, which probably makes the experts laugh (using ''/bin/bash'' and ''as arguments''):
for f in "$@"
do
/usr/local/bin/exiftool -FileModifyDate<DateTimeOriginal "$f"
done
Could somebody please adjust my beginner mistakes? As a convenience, I added the automator task as an attachment.
Thank you in advance, and best regards,
Julien
Try
exiftool "-FileModifyDate<DateTimeOriginal" DIRinstead of looping through the files.
Note, I haven't tested this but it is similar to the help information
Quoteexiftool '-FileModifyDate<DateTimeOriginal' dir
Use the original date from the meta information to set the same
file's filesystem modification date for all images in a directory.
(Note that "-TagsFromFile @" is assumed if no other -TagsFromFile
is specified when redirecting information as in this example.)
Edit:
or, in your shell script
exiftool "-FileModifyDate<DateTimeOriginal" "$@"
Dear Alan,
Thank you for the very quick reply!
I just tried adding DIR in the shell script within Automator. It now looks like this:
for f in "$@"
do
/usr/local/bin/exiftool "-FileModifyDate<DateTimeOriginal" DIR
done
When I launch the Automator task, it gives the following error:
Warning: Error opening file - DIR
Error: File not found - DIR
You were meant to enter any valid directory name, not "DIR" literally.
This all is a magic language to me. I was already happy to make it work in Terminal, but Shell Scripts in Automator are a whole new level.
Thanks for all the help already!
Dear Alan, you are a king!
Your last edit worked!
for f in "$@"
do
/usr/local/bin/exiftool "-FileModifyDate<DateTimeOriginal" "$@"
done
For everyone in the future who is struggling with the same issue, I added the working Automator Task attached.
I was thinking without the loop in the shell
for f in "$@"
do
/usr/local/bin/exiftool "-FileModifyDate<DateTimeOriginal" "$@"
done
Even better indeed! Thanks Alan