Hi,
I have a working exiftool command that copies, updates metadata and renames image file stored in one directory into a new directory on a different volume. I’m running this command as a shortcut generated by Apple’s Automator Application.
The present shortcut is fine except when it processes image files that have already been processed. The attempt to create duplicate filenames throws an error that lists all the images that have not been created. This is not a problem as all the other files are processed correctly. However it would be great to be able to trap and present the error message in a better way.
My plan is to run the shell script from within an Applescript which will trap the error and present a more useful message, something along the lines of “37 files were not processed as they already existed in the destination folder”. Hopefully you get the idea.
Here is the fully working shell script that can be run inside an Automator Shortcut. The shortcut starts with the path to the folder selected in the Finder and this path is passed to the shell script by Automator via its output / input between workflow steps.
/usr/local/bin/exiftool -m -r '-XMP:TransmissionReference<Filename' '-copyright<(c)${CreateDate#;DateFmt("%Y")} Simon Knight All rights reserved.' '-XMP:PreservedFilename<Filename' '-XMP:Title<Filename' '-IPTC:ObjectName<Filename' '-FileName<CreateDate' -d /Volumes/Images_Disc_02_Master/TempTestImageUpdated/%Y_%m/%Y_%m_%d_%H%M%S_%%f.%%e "$@"
The first steps in the command set values in the current image file, these steps are followed by -d and the path to the destination folder. Each file is renamed with a date stamp as a prefix e.g. 2025_02_05_103725_originalFileName.Extn. The final clause “$@” appears to be where the shell script fails when run from Applescript. I believe that this clause iterates over the files in the folder.
I have copied this into an Do Applescript section of an Automator shortcut and it looks like this:
on run {input, parameters}
display dialog "Input is set to : " & input
--display dialog "parameters is set to : " & parameters
set Mycmd to "/usr/local/bin/exiftool -m -r '-XMP:TransmissionReference<Filename' '-copyright<©${CreateDate#;DateFmt(\"%Y\")} Simon Knight All rights reserved.' '-XMP:PreservedFilename<Filename' '-XMP:Title<Filename' '-IPTC:ObjectName<Filename' '-FileName<CreateDate' -d /Volumes/Images_Disc_02_Master/TempTestImageUpdated/%Y_%m/%Y_%m_%d_%H%M%S_%%f.%%e '$@' " & input
do shell script (Mycmd)
--return input
end run
When run the Applescript posts an error stating that it is unable to find the file, followed by the path to the selected folder (please see attached screen shot). Lumix:DCIM:113_PANA is the path to a folder of images on a SD card.
I have experimented with how the “$@” is entered and have tried single quotes, escaped double
quotes and using the Applescript constant ‘quote’ & “$@” & ‘quote’ but unfortunately so far I have been unable to get the script to run.
I have attached my non-working workflow:
Ingest images WIP.workflow.zip (94.2 KB)
Any thoughts ?