Pick of the Week - Nov 10 [Show all picks]
Path Finder 5 - A feature-laden Finder replacement
Submit Hint Search The Forums LinksStatsPollsFAQHeadlinesRSS
12,000 hints and counting!


Click here to return to the 'Use launchd to replace folder actions' hint
The following comments are owned by whomever posted them. This site is not responsible for what they say.
Use launchd to replace folder actions
Authored by: mjb on Wed, Apr 23 2008 at 2:01PM PDT
Why not just add the deletion if the .DS_Store file to the end of the shell script launchd calls? Something like:

#!/bin/sh

osascript /path/to/applescript.scpt

DSSTORE='/path/to/a/folder/.DS_Store'
if [ -f $DSSTORE ];then
   rm $DSSTORE
fi


[ Reply to This | # ]
Use launchd to replace folder actions
Authored by: squawbrah on Wed, Apr 23 2008 at 5:44PM PDT
Nice hint. I discovered two things when I tried it out:

1) You should probably use WatchPaths instead of QueueDirectories to prevent an endless loop and also (I think) eliminate the problem with .DS_Store files.

When I tried a simple folder action--making a file's label turn red when put in the target folder--with QueueDirectories, my CPU use jacked way up and never came down. Using WatchPaths instead solved the problem.

2) You can call an AppleScript directly--instead of having a shell script call an AppleScript--by putting this in your .plist file:

<key>Program</key>
<string>/usr/bin/osascript</string>
<key>ProgramArguments</key>
<array>
<string>osascript</string>
<string>/Users/foo/path/to/myscript.scpt</string>
</array>

Lots more info at http://www.afp548.com/article.php?story=20050620071558293

--Thanks



[ Reply to This | # ]