exiftool el capitan 10.11

Discussion in 'Mac Programming' started by 537635, Aug 8, 2015.

  1. 537635 macrumors 6502

    Joined:
    Mar 7, 2009
    #1
    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.

    [​IMG]

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

    [​IMG]

    Thanks!
     
  2. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #2
    You need to test that on the command line and see what the actual error may be.
     
  3. 537635 thread starter macrumors 6502

    Joined:
    Mar 7, 2009
    #3
    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.
     
  4. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #4
    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.
     
  5. 537635 thread starter macrumors 6502

    Joined:
    Mar 7, 2009
    #5
    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
    
     
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    Do this in a Terminal window, then paste the entire exact output into a reply here:
    Code:
    echo "$PATH" ; type exiftool
     
  7. 537635 thread starter macrumors 6502

    Joined:
    Mar 7, 2009
    #7
    Code:
    111111:~ 1111111$ echo "$PATH" ; type exiftool
    /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
    exiftool is /usr/local/bin/exiftool
    
     
  8. chown33, Aug 10, 2015
    Last edited: Aug 10, 2015

    chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #8
    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
    
     
  9. 537635 thread starter macrumors 6502

    Joined:
    Mar 7, 2009
    #9
    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... ???
     
  10. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #10
    Glad to have helped.


    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.
     
  11. 537635 thread starter macrumors 6502

    Joined:
    Mar 7, 2009
    #11
    How about the latest upgrade of the ExifTool?

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

     
  12. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #12
    Yes, that would also explain things completely.
     
  13. Chris Kobrzak macrumors newbie

    Chris Kobrzak

    Joined:
    Oct 23, 2015
    Location:
    London, England
    #13
    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.
     

Share This Page