I have a script that I am getting ready to write for watermarking a bunch of images. I was thinking of using a folder action to make it easier on the user. There will probably be 1,000 images dropped into the folder to process at once. Is there a speed hit in doing this as a folder action? I have always used dropplets before and could easily do so now. If anyone has any experience with this some advice would be helpfull…if not I will run some tests.
My usual approach is either to use droplets or stay-open background “on idle” scripts watching a designated folder for this kind of task – Folder Actions can get swamped because they’ll start processing before all the dropped files are registered and thus can miss some. I use Drop Script Backgrounder to turn an on-idle stay-open script app into a background application, and make sure it starts up at login time.
Adam
While that might be a solution, could it be more elegant to have a single event that keeps counting until the number of items remains stable, i.e. something of the like:
set {DropCount, PrevDropcount} to {1, 0}
repeat until DropCount = PrevDropcount
set PrevDropcount to DropCount
tell application "Finder" to update folder x
do shell script "Sleep 1"
tell application "Finder" to set DropCount to count of items of folder x
do shell script "Sleep 1"
end repeat
I haven’t tried it, but definitely like it – I’ve used a similar method for checking whether a file has been copied:
to IsSizeStable(myFile) -- can be a folder too
-- initialize the loop
set Size_1 to 0
set Size_2 to 1
-- repeat until sizes match
repeat while Size_2 ≠Size_1 -- loop until they're equal
set Size_1 to Size_2 -- new base size
do shell script "sleep 3" --wait three seconds, or whatever
set Size_2 to size of (info for myFile) -- get a newer size
end repeat -- once the sizes match, the download is done
end IsSizeStable
and John Welch in another forum posted this one:
-- John C. Welch
on adding folder items to theFolder after receiving theAddedItems
-- tell application "Finder" to set theFolderName to name of theFolder
repeat with x in theAddedItems
set theFileInfo to info for x --get info for the downloading file(s)
set theBaseSize to size of theFileInfo --get initial size
delay 3 --wait 3 seconds
set theFileInfo to info for x --get info again
set theCompareSize to size of theFileInfo --get a newer size
repeat while theCompareSize ≠theBaseSize --if they don't equal, loop until they do
set theBaseSize to theCompareSize --new base size
delay 3 --wait three seconds
set theFileInfo to info for x --get info
set theCompareSize to size of theFileInfo --get a newer size
end repeat --once the sizes match, the download is done
end repeat
end adding folder items to
Thanks for reminding me.