A large percentage of AppleScripts are writtten to process files in a programmatic fashion. At the successful conclusion of that processing, I would like to move the original files (that I have carefully preserved to this point, allowing for a graceful back-out should problems arise) to the trash. This is all pretty mundane, until you try to run your script against files on a mounted disk from another system. OS X doesn't like to allow this, I suspect due to sound security concerns. But I did find a graceful way around this, that works whether you are running the script locally or remotely.
I first set up an intermediate folder, let's call it "dumpster," and attach a Folder Action Script that looks like this to it:
on adding folder items to this_folder after receiving these_items
tell application "Finder"
move these_items to the trash
end tell
end adding folder items to
You do this by copying the above text into a script file (or copy an existing Folder Action Script, renaming the copy to "dumpster.scpt," and replace the contents with the code shown above), placing your new Folder Action Script into the /Library/Scripts/Folder Action Scripts folder, and then using the Attach Script to Folder script in the Scripts menu pulldown to associate your new Folder Action Script with your newly created "dumpster" folder. Now anything placed in the "dumpster" folder is immediately moved to the Trash.
Since this happens on the machine whose disk is remotely attached, it requires no explicit action from the remote system to activate it -- just moving files into it will result in those files being moved to the Trash. Now all we need to do in our file-processing AppleScript, when the time comes that we want to move files to the Trash, is to insert the following lines of code:
tell application "Finder"
set dumpsterFolder to (get folder (POSIX file dumpster as text))
set sourceFolder to (get folder (POSIX file sourceFolderPath as text))
move file sourceDoc of sourceFolder to dumpsterFolder
end tell
It may well be possible to simplify the two set statements from the way they are presented above, but it works for me.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20050517185222756