3

I have a custom Service I created in Automator. Right now, the service shows up in my context (right-click) menu, when right-clicking on any folder. In Automator, I added the Run AppleScript action, to execute this code:

on run {input, parameters}
    do shell script "/usr/bin/find ./ -type f -name .DS_Store -delete -print"
    return input
end run

My objective is to delete all .DS_Store files in the selected folder (and all folders within it). I normally do this in Terminal by executing /usr/bin/find /path-to-folder -type f -name .DS_Store -delete -print, but I would love to get this to work from my custom Service.

I'm thinking I need to pass the selected folders path to the AppleScript function (through input perhaps?), but I have no idea how, nor do I see any actions in Automator to pass this. I'm using OS X 10.6.5. Any ideas or suggestions?

2

At the top of the screen, above your action, there should be a list-box that says Service receives selected <text> in <any application>. Changing <text> to folders should give you the folders as input.

  • Thank you. That's it. You wouldn't happen to also know how to convert the path it passes Macintosh HD:Users:Matthew:Documents:Programming:Apple Scripts: to a path like Macintosh\ HD/Users/Matthew/Documents/Programming/Apple\ Scripts? – matthewpavkov Dec 14 '10 at 3:33
  • @matthewpavkov: unfortunately no... but there might be a command line utility. feel free to create another question, I'm sure someone around here knows :P – Robert S Ciaccio Dec 14 '10 at 3:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .