Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

537635

macrumors 65816
Original poster
Mar 7, 2009
1,169
1,049
Slovenia, EU
I am using exif tool and an Automator script to select files in finder and then run the script to rename files using the CreateDate EXIF tag.

izELpev.png


Now this happens, when I run this script via Finder in ElCapitan. In Yosemite and before it worked fine...

yDEzroK.png


Thanks!
 
In command line in works normally. I only replace "$f" with the folder name.

It's as if the syntax in Automator has changed or maybe it's a problem because exiftool is a 3rd party program. I am not a programmer but I taught myself as much to do this script (or copy it from various sources).

So I have no idea where to even look for a problem. Any further help would be appreciated.
 
On the exiftool web page:
http://www.sno.phy.queensu.ca/~phil/exiftool/

It shows this example:
Code:
exiftool "-FileName<CreateDate" -d "%Y%m%d_%H%M%S.%%e" DIR
Your quoting is different. I suggest changing your quoting to match the example.

In particular, make sure the percent symbols are enclosed in quotes. Bash uses % as job control identifiers, so unquoted percents are vulnerable to bash substitution.


You can inspect the commands the shell executes by adding this line before your 'for' loop:
Code:
set -x
The output will be every command, fully expanded. You can read about this option in the bash man page.

If you don't see a problem, then post the output and maybe someone else will.


You can also do a number of simplified tests:
1. Replace the 'exiftool' line with a simple echo "$f"
2. Replace the 'exiftool' command in the original line with 'echo'.

In short, break it down, try parts one by one, and observe output to see what actually happens.
 
Thank you very much for taking the time.

I corrected the exiftool command itself, although it ran without problems in Yosemite.

Code:
set -x
for f in "$@"
do
    exiftool "-FileName<CreateDate" -d "%Y%m%d %H%M%S%%-c.%%e" $f
done



The run test inside Automator shows this:

Code:
+ for f in '"$@"'
+ exiftool '-FileName<CreateDate' -d '%Y%m%d %H%M%S%%-c.%%e' /Users/xxxxx/Downloads/123/xxxxxxxx.jpg
-: line 3: exiftool: command not found
+ for f in '"$@"'
+ exiftool '-FileName<CreateDate' -d '%Y%m%d %H%M%S%%-c.%%e' /Users/xxxxx/Downloads/123/xxxxxxxx.jpg
-: line 3: exiftool: command not found
 
Do this in a Terminal window, then paste the entire exact output into a reply here:
Code:
echo "$PATH" ; type exiftool
 
Code:
111111:~ 1111111$ echo "$PATH" ; type exiftool
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
exiftool is /usr/local/bin/exiftool
 
Code:
111111:~ 1111111$ echo "$PATH" ; type exiftool
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
exiftool is /usr/local/bin/exiftool
Thanks. Now do the same for an Automator Run Shell Script action, and post the output.

I strongly suspect that /usr/local/bin won't be in the PATH of the Automator action. There are ways to address this if it's really the cause, but we first need to confirm this is what's happening.

Or the quick and simple fix is to use this as the command in the Automator action:
Code:
/usr/local/bin/exiftool '-FileName<CreateDate' ...OTHER_ARGS_HERE
 
Last edited:
You are absolutely correct!

Code:
+ echo /usr/bin:/bin:/usr/sbin:/sbin
+ type exiftool
-: line 1: type: exiftool: not found
+ for f in '"$@"'
+ exiftool '-FileName<CreateDate' -d '%Y%m%d %H%M%S%%-c.%%e' /Users/123/Downloads/123/img_0101.jpg
-: line 4: exiftool: command not found
+ for f in '"$@"'
+ exiftool '-FileName<CreateDate' -d '%Y%m%d %H%M%S%%-c.%%e' /Users/123/Downloads/123/img_0102.jpg
-: line 4: exiftool: command not found


Did your quick&simple fix and the script works again. Thank you so much for taking the time and solving this.


Now for the question why it stopped working with El Capitan... ???
 
Did your quick&simple fix and the script works again. Thank you so much for taking the time and solving this.
Glad to have helped.


Now for the question why it stopped working with El Capitan... ???
I'm pretty sure that /usr/local/bin has never been a standard part of the PATH variable. That suggests you must have customized one of the shell's startup files at some point in the past. I can give you Terminal commands to look into it if you want to do that. Or read the 'bash' man page, under the INVOCATION heading, and look for the files using 'ls':
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/bash.1.html

Another possibility is that you have customized environment variables, again set at some time in the past. There are (or were) System Preferences panes that did this, but I can't point you to one directly, as I don't have access to a relevant machine right now. After googling it, RCEnvironment is one (search terms: system preferences environment variables). I don't know if it works now, nor when it may have stopped working.

In any case, whatever was setting PATH before must have stopped working in El Cap. This may be because it's a beta, or because of heightened security (spoofing PATH is a security trap for the unwary), or for any other reason.
 
How about the latest upgrade of the ExifTool?

I have never messed (knowingly) with any system files whatsoever...

July 23, 2015 - Version 9.99
....
Fixed problem where a partial command could be executed if the -stay_open option was used and the command is aborted due to an error in arguments
Fixed problem with OS X installer on El Capitan (now installs in /usr/local/bin instead of /usr/bin)
API Changes:
Added SystemTags option
 
Sorry for a late reply but I've just bumped into an identical problem.

The way I fixed my broken Automator script is I've added the following statement to the Shell script:

Code:
PATH="/usr/local/bin:$PATH"

Otherwise Automator wouldn't know exiftool sits under /usr/local/bin.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.