Page 1 of 1

Error with Exiftool script

PostPosted: Sat Feb 20, 2016 6:55 pm
by rpedro
Hi,
I'm trying to create a rule to rename image files using Exiftool with the following Script:
Code: Select all
exiftool -d %Y-%m-%d_%H%M%S '-filename<${DateTimeOriginal;}.%e' "$1"


Hazel returns an error processing shell script, here is the log:
Code: Select all
2016-02-20 19:47:32.274 hazelworker[25836] Processing folder Fotos IN
2016-02-20 19:47:34.369 hazelworker[25836] DSC 323200.jpg: Rule fotos rename matched.
2016-02-20 19:47:34.372 hazelworker[25836] Exception caught while executing shell script: launch path not accessible
2016-02-20 19:47:34.373 hazelworker[25836] [Error] Shell script failed: Error processing shell script on file /Volumes/Data HD/Pictures/Fotos IN/DSC 323200.jpg.
2016-02-20 19:47:34.373 hazelworker[25836] Shellscript exited with non-successful status code: -900
2016-02-20 19:47:34.381 hazelworker[25836] Done processing folder Fotos IN


The script works in Terminal, I replaced "$1" with the filename for testing purposes, like this:
Code: Select all
exiftool -d %Y-%m-%d_%H%M%S '-filename<${DateTimeOriginal;}.%e' /path/filename.jpg


What am I doing wrong?

Re: Error with Exiftool script

PostPosted: Mon Feb 22, 2016 12:15 pm
by Mr_Noodle
Try specifying a full path for exiftool. In scripts, you cannot assume that environment variables are set as they are in Terminal.

Re: Error with Exiftool script

PostPosted: Mon Feb 22, 2016 9:34 pm
by brudderman
You might try putting in single quotes around your date pattern and see if that helps:

Code: Select all
exiftool -d  '%Y-%m-%d_%H%M%S'  '-filename<${DateTimeOriginal;}.%e' "$1"

Re: Error with Exiftool script

PostPosted: Tue Feb 23, 2016 6:18 pm
by rpedro
I tried full path:
Code: Select all
usr/local/bin/exiftool -d  %Y-%m-%d_%H%M%S  '-filename<${DateTimeOriginal;}.%e' "$1"

Also tried single quotes, and tried both together.
None of them worked.

Is there anything else I can do?

Thanks for the help guys.

Re: Error with Exiftool script

PostPosted: Tue Feb 23, 2016 11:18 pm
by brudderman
I don't know why your syntax is failing, but here's what works for me with a different naming convention:

Code: Select all
exiftool  -d '%Y-%m-%d ' '-filename<${directory;s(.*/)()} ${DateTimeOriginal;}  %.3c.%le' "$1"


Note that single quotes surround the date pattern %Y-%m-%d even though they may be hard to see. And I had a lot of trouble with single quotes that were really "smart" or "curly" quotes that had to be corrected.

Re: Error with Exiftool script

PostPosted: Wed Feb 24, 2016 11:16 am
by Mr_Noodle
Is it a typo in your post or are you missing the initial "/" in the path?

Re: Error with Exiftool script

PostPosted: Thu Feb 25, 2016 7:19 am
by rpedro
Mr_Noodle wrote:Is it a typo in your post or are you missing the initial "/" in the path?


It was a typo, sorry. The correct line is:
Code: Select all
/usr/local/bin/exiftool -d  %Y-%m-%d_%H%M%S  '-filename<${DateTimeOriginal;}.%e' "$1"

It's not working, really don't know what's going on.

Re: Error with Exiftool script

PostPosted: Thu Feb 25, 2016 11:48 am
by Mr_Noodle
Are you getting the same error in the logs? Also, turn on debug mode (see sticky article about it) to get direct output from the script in the logs.

Re: Error with Exiftool script

PostPosted: Fri Feb 26, 2016 6:20 am
by rpedro
Mr_Noodle wrote:Are you getting the same error in the logs? Also, turn on debug mode (see sticky article about it) to get direct output from the script in the logs.

Yes, same error logs. I'll try debug mode and report back.

Re: Error with Exiftool script

PostPosted: Fri Feb 26, 2016 11:57 am
by Mr_Noodle
BTW, is this an embedded script or external? Also, what do you have listed as the shell to use?

Re: Error with Exiftool script

PostPosted: Fri Feb 26, 2016 1:29 pm
by rpedro
Yes, its an embedded script and shell is bin/bash.

Here's what DEBUG reports:
Code: Select all
016-02-26 14:30:42.062 hazelworker[94810] DEBUG: Processing directories: (
    "/Volumes/Data HD/Pictures/Fotos IN"
)
2016-02-26 14:30:42.069 hazelworker[94810] DEBUG: Received file event: {
    date = "2016-02-26 17:30:39 +0000";
    path = "<ComNoodlesoft_NoodlePathSet: 0x7fc5ebd4a870> - (\n    \"/Volumes/Data HD/Pictures/Fotos IN\"\n)";
}
2016-02-26 14:30:42.069 hazelworker[94810] DEBUG: About to process directory /Volumes/Data HD/Pictures/Fotos IN
2016-02-26 14:30:42.074 hazelworker[94810] DEBUG: .DS_Store: File is hidden/invisible. Skipping.
2016-02-26 14:30:42.085 hazelworker[94810] DSC 3523214.jpg: Rule fotos rename matched.
2016-02-26 14:30:42.085 hazelworker[94810] DEBUG: Got error last time. Re-trying actions.
2016-02-26 14:30:42.559 hazelworker[94810] Exception caught while executing shell script: launch path not accessible
2016-02-26 14:30:42.570 hazelworker[94810] [Error] Shell script failed: Error processing shell script on file /Volumes/Data HD/Pictures/Fotos IN/DSC 3523214.jpg.
2016-02-26 14:30:42.714 hazelworker[94810] Shellscript exited with non-successful status code: -900
2016-02-26 14:30:42.714 hazelworker[94810] DEBUG: Tapping error retry sequence
2016-02-26 14:30:42.715 hazelworker[94810] DEBUG: Writing out DB file: /Volumes/Data HD/Pictures/Fotos IN
2016-02-26 14:30:42.749 hazelworker[94810] DEBUG: Directory /Volumes/Data HD/Pictures/Fotos IN processed in 0.679884 seconds
2016-02-26 14:30:42.762 hazelworker[94810] DEBUG: Sending metrics to scheduler. Next scheduled run: 2016-02-26 15:30:42.714
2016-02-26 14:30:42.765 hazelworker[94810] Done processing folder Fotos IN

Re: Error with Exiftool script

PostPosted: Fri Feb 26, 2016 2:22 pm
by Mr_Noodle
Err, again, I see a missing leading slash. Do you actually have the shell specified as "bin/bash" or is that a typo? It really should be "/bin/bash"

Re: Error with Exiftool script

PostPosted: Fri Feb 26, 2016 4:01 pm
by rpedro
Oh man, I fell silly. :?
/bin/bash solved it, I even removed full path for Exiftool.
Thanks a lot. :)