4 Replies Latest reply: Mar 6, 2013 8:00 PM by pjdube
phillio Level 1 Level 1 (0 points)
Hi - I'm trying to add a Service (using Automator) that would allow you to unlock all the files in a selected folder and having an issue with limiting the scope of the action to that folder.

In Automator, I've created a new Service called Unlock Files. It's set to receive Selected Folders in Finder.app. The next step runs a shell script, "chflags -R nouchg ./"

This results in my entire drive being unlocked, not just the folder in question when I run that service in the Finder.

Thoughts?

Thanks
Phil

Mac Pro, Macbook, Mac OS X (10.6.6)
  • 1. Re: Add Service to unlock folder/files
    Camelot Level 8 Level 8 (45,790 points)
    The next step runs a shell script, "chflags -R nouchg ./"


    Sure. That command, as written, will do precisely what you say. There is nothing in the shell command to indicate which folder(s) to work on.

    You need to actually pass the folder(s) from the previous step into the shell command.

    You need to use the popup menu in the upper-right corner of the run shell command action to change your shell action to take the inputs as arguments rather than the default as stdin. This will essentially rewrite the shell command to loop through the arguments, running the chflags as appropriate:

    for f in "$@"
    do
    chflags -R nouchg "$f"
    done
  • 2. Re: Add Service to unlock folder/files
    phillio Level 1 Level 1 (0 points)
    Thanks so much for your help! Please forgive my newness to these things (I'm a video guy) but are you saying that all I have to do is change the pulldown to 'arguments' instead of 'stdin' (and I would love to know what stdin is)? Or do I have to change the shell command to your example as well?
  • 3. Re: Add Service to unlock folder/files
    Camelot Level 8 Level 8 (45,790 points)
    but are you saying that all I have to do is change the pulldown to 'arguments' instead of 'stdin' (and I would love to know what stdin is)? Or do I have to change the shell command to your example as well?


    You'll have to change the script, too.

    The bulk of the re-written script is just a loop that iterates through the items passed in as arguments, running the chflags command for each item (there could be more than one).

    As for stdin vs arguments, some shell commands can take their input from the command line and process them - this is what happens, for example, when you pipe some data through grep - the output of one command (stdout) becomes the input data for the next (stdin).

    In this case, chflags doesn't care about stdin since it expects all its data to be passed in on the command line, hence the need to pass the data as arguments.
  • 4. Re: Add Service to unlock folder/files
    pjdube Level 3 Level 3 (830 points)

    Hey Phil,

     

    Here is the Automator action you need. It's called "Unlock Finder Items" You can get it from here:

     

    http://www.automatedworkflows.com

     

    There is a Finder Automator Action pack that you can purchase (really cheap) to get this action and about 20 other awesome actions.

     

    See below service:

     

    Screen Shot 2013-03-06 at 9.54.19 PM.JPG

     

    I tested it and it works great.

     

    Good luck!

     

    Regards,

     

    Phil