Running shell script on subfolder contents

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

Moderator: Mr_Noodle

Running shell script on subfolder contents Mon Jul 22, 2013 12:56 pm • by Greg Jones
I could use some guidance on getting a shell script to run on the contents of a folder, and its subfolder(s). What I have is a situation where an app creates a .plist file for every document it creates in a folder. I want to set all the .plist files to hidden so that they don't clutter the folder.

I have set up the following Hazel rule, and it works properly on the folder it is assigned to:
Image

Now, I have also added the 'Go Into subfolders' rule to the top of the rules list, but the rule does not work properly on the .plist documents in the subfolders. I get an error message:

Code: Select all
Error] Shell script failed: Error processing shell script on file /Users/.../Sub folder/xxxx.txt.plist.


If I create any simple rules such as setting the document color, etc., the rule runs fine on the subfolder contents. I suspect that this is a path issue, but I have almost zero knowledge of writing shell scripts so I am at a loss on what to try. Any suggestions?
Greg Jones
 
Posts: 6
Joined: Sun Oct 28, 2012 7:53 am

Your script does not do anything with the passed in path ($1). As a result, it will set to hidden all the files in whatever the current directory happens to be (which can be unpredictable in this case). Just change *.plist to "$1" (including the quotes).
Mr_Noodle
Site Admin
 
Posts: 11865
Joined: Sun Sep 03, 2006 1:30 am
Location: New York City

Yes, it took a while for all the files to start disappearing, but eventually it happened! The change in the script works perfectly-thank you so much.
Greg Jones
 
Posts: 6
Joined: Sun Oct 28, 2012 7:53 am


Return to Support