I’m working on a droplet that will reside on each user’s hardrive. The users grab folders from a server and drop them onto their script, which does some file moving and renaming and such, and writes some file info to their personal log files. The problem is, multiple users may try to access the same folders at once. I’d like to make it so this won’t cause problems. For instance, the script will know that a particular folder is in use by someone else, and skips to the next. So, if two people drop the same ten folders on their scripts at the same time, maybe one person will end up processing 6, and the other 4. Is this possible??? Thanks again… 8)
I don’t know of a built-in way to detect this but maybe the droplets could, as the very first step, write a file to any folder that they are working on. This could act as a flag that indicates that the folder is being processed by someone else.
That was a good idea. I used a “Temp” file as a flag, threw it in a try block, and it works fine. I had 4 users trying to access the same 50 folders at once, and the scripts duked it out.
on open theseFolders
repeat with aFolder in theseFolders
tell application "Finder"
activate
try
if (exists of file "Temp" of folder aFolder) is false then
make new file at folder aFolder with properties {name:"Temp"}
my doTheRestOfTheScript(aFolder)
end if
end try
end tell
end repeat
beep 3
end open