shell script to change file modification date does nothing

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

Moderator: Mr_Noodle

Hello all,

tldr: shell script does nothing, not even an error

I'm in need for a little help with a Hazel rule I'm trying to build.

The rule selects files from multiple sub-directories based on some criteria, then copies them to another folder. So far so good, all working.

After the copy, I need to change the modification date of the copied file so that I can see long it has been since it was copied. I created a shell script that executes

Code: Select all
touch -mac $1


I tested that command on the shell and it does what I need.

The problem is, when it gets executed within Hazel nothing happens. In the logs theres no indication of an error or anything. I tried adding in echo commands, in the hopes that those would get written down in the logs, but nothing.

Now, I wonder whether the command gets even executed, or if there's some other error going on. The file date don't get modified either...

Anyone got a hint?

edit: typos
Kentar_lux
 
Posts: 5
Joined: Tue May 29, 2012 2:39 pm

Turn on debug mode (sticky article near top of this forum). That will show you the output of any scripts. Also, you might want to put $1 within double quotes in case the path has spaces in it.
Mr_Noodle
Site Admin
 
Posts: 11255
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Cool, didn't know about debug mode. Will check that out :)

But the double quotes helped! Of course there were spaces in my path so this fixed it. Nice!!

Thanks Mr. Noodle, for Hazel and for always being watchful and helpful in the forums.

Cheers!
Kentar_lux
 
Posts: 5
Joined: Tue May 29, 2012 2:39 pm


Return to Support