Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Use launchd to replace folder actions' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use launchd to replace folder actions
Authored by: TheCrunge on Apr 24, '08 07:09:41AM
The biggest problem I've found with using launch daemons is that you can't pass the name of the added item. Using folder actions, you can get the name and the path of each item added. For example:
on adding folder items to this_folder after receiving added_items
         repeat with the_item in added_items
                   set the_posix to POSIX path of the the_item
                   display dialog "The added item is " & the_item & " and is located at " & the_posix
         end repeat
end adding folder items to
Using launch daemons, there is no argument passed to your script providing the name or the path of the item. It makes it difficult to manipulate this new file without knowing it's name or path. Am I wrong?

[ Reply to This | # ]
Use launchd to replace folder actions
Authored by: Zeitkind on Apr 24, '08 01:16:29PM

It simply depends on your needs. In my case, I know that there will be one to many tiff-files which need to be ocr'ed. It's very simple to get a list of files with AppleScript:
tell application "Finder"
set myFolder to alias "Volumename:path:to:folder:"
set myList to every file of myFolder as alias list
end tell
You then have an array with all the files as alias. With a repeat or while or whatever kind of loop you can process the files.

[ Reply to This | # ]
Use launchd to replace folder actions
Authored by: ceesaxp on May 02, '08 10:23:51PM
Well, I suppose (have not tried) that launchd when calling would be passing it each item one-by-one (i.e. calling it several times if multiple items were added). In case of /bin/sh they will be known to shell script as $1, and then will be passed over to AppleScript. So, you should have all the same (or similar) info and control, no?

[ Reply to This | # ]