Change Modification/Access Time on Images and Then Move

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

I am attempting to use Hazel to change the modification and access times on images placed into a particular folder and then to move those image to a new folder. Whenever the rule runs, I get an error in the logs saying that the shell script failed. Here is the shell script I am currently using:

Code: Select all
touch -afm


The only check this rule makes is whether or not the file is an image. After the check and the command, it should move the file to a new folder, but it never gets that far as the aforementioned command fails every time.
Zyniker
 
Posts: 12
Joined: Fri Oct 18, 2013 5:42 pm

There's no argument to the touch command. $1 is passed in as the file being matched so you want to use that. To be safe, enclose it in double quotes.

Code: Select all
touch -afm "$1"
Mr_Noodle
Site Admin
 
Posts: 11867
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

That's actually what I have for the shell script. This is the error it throws every time the rule is run:
Code: Select all
hazelworker[43613] Shellscript exited with non-successful status code: 1
Zyniker
 
Posts: 12
Joined: Fri Oct 18, 2013 5:42 pm

Try debugging the script outside of Hazel.
Mr_Noodle
Site Admin
 
Posts: 11867
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

What you posted in your first reply is literally the entire script. There's nothing to debug.
Zyniker
 
Posts: 12
Joined: Fri Oct 18, 2013 5:42 pm

So what happens when you run that script manually with the file it is failing on? Does it work or do you get an error?

Also, turn on debug mode as described in the sticky article at the top of this forum. That will show the output (though there may not be any in this case). Lastly, use the full path for the "touch" command to see if that changes anything.
Mr_Noodle
Site Admin
 
Posts: 11867
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

The command works precisely as expected when run outside of Hazel.
Zyniker
 
Posts: 12
Joined: Fri Oct 18, 2013 5:42 pm

How about the other things I suggested?
Mr_Noodle
Site Admin
 
Posts: 11867
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

I've turned on debug mode. Here are the contents of the log file when I run the rule:

Code: Select all
2015-03-17 17:15:23.021 hazelworker[89227] cloud.png: Rule Change Modification Date and Move to Optimize matched.
2015-03-17 17:15:23.021 hazelworker[89227] DEBUG: Manual run. Forcing actions to be executed.
2015-03-17 17:15:23.023 hazelworker[89227] Exception caught while executing shell script: Couldn't posix_spawn: error 13
2015-03-17 17:15:23.024 hazelworker[89227] [Error] Shell script failed: Error processing shell script on file /Users/ ... ImageOptim Staging/cloud.png.
2015-03-17 17:15:23.024 hazelworker[89227] Shellscript exited with non-successful status code: -900
2015-03-17 17:15:23.024 hazelworker[89227] DEBUG: Tapping error retry sequence
Zyniker
 
Posts: 12
Joined: Fri Oct 18, 2013 5:42 pm

What shell do you have listed in the shell field? Make sure that points to valid script interpreter.
Mr_Noodle
Site Admin
 
Posts: 11867
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

It was using /usr/bin/false. I swapped it over to /usr/bin/true and now it appears to be working. Thanks for the help.
Zyniker
 
Posts: 12
Joined: Fri Oct 18, 2013 5:42 pm

Err, that's not correct either. true always returns true and is not a real shell. You need to use something like /bin/sh.
Mr_Noodle
Site Admin
 
Posts: 11867
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City


Return to Support