...
So at this stage, if everything is set up correctly, the files should actually be processed by Exiftool, or just simulated to do so? ...
Given what you posted, it's just simulating the command. More specifically, it's echoing the text of a command, but it's not actually executing it.
So you now have the basic structure in place. Next, you have to put the command in there correctly. To do that, we have to understand exactly what the original was doing, and what this script is expected to do.
First, the original consists of two commands, not one. The
"cd" to the folder with the files I want processed is a crucial command, because it sets the context for the 'exiftool' command line. Without the correct directory, the 'exiftool' command won't do what you want.
Second, the way the command-line is written, it processes an entire directory of files, recursively (I looked this up in the online 'exiftool' man page). So the script will have to do the same thing. This implies that the Automator workflow should only process folders dropped onto it. The shell script can do that, but it will be easier to understand if you use another Automator action.
The Automator action is "Filter Finder Items". Place it before the "Run Shell Script" action. Then use the popups to select these:
(All) of the following are true
(Kind) (is) (folder)
I've shown the popups as parenthesized words.
To test, you should revert to the
echo "$f" command, and make sure that only folders appear in Results. That is, if you drop files on it directly, or in the "Get specified Finder items" action, those files should be ignored, and not appear in the Results output.
Next, it's important to understand what the
"$f" represents. It's each item produced by the prior action, which should only be folder names.
There are two ways to handle this folder. You could 'cd' to it, then run the 'exiftool' command line, just like you did manually. Or you can skip the 'cd' command and tell 'exiftool' to work directly on the folder. I'll show the command-line for the 2nd.
Replace the entire script in the Run Shell Script step with this:
Code:
for f in "$@"
do
exiftool -r '-alldates<MDItemContentCreationDate' -keywords+=DateModified -if '!$datetimeoriginal' "$f" -overwrite_original
done
You should be able to copy and paste that exactly as shown.
Notice that I've replaced the dot in the original with
"$f" (the quotes are required). That original dot means "the current directory", which in the original context means "the directory you just cd'ed to".
Here, the
"$f" means "the input item", and the quotes ensure that any spaces or other special characters are kept as part of the folder name.
If you run the workflow at this point, you should be getting folders of images with the creation date changed. Test it.
If everything works, you can disable the "Get specified Finder items" action (right-click it, choose "Disable"). You could also delete it, but if you ever have to revise the workflow, you'd probably add it back. Disabling preserves the step without running it. Again, test this.
As an exercise, you could try the two-command version yourself. That is, write the shell commands that 'cd' to the folder, then run 'exiftool' on it.