Hi there guys. I am trying to create a folder action to move files. Multiple users are dropping files to a watched folder with this script attached. What I need is for files to be moved to a second folder once they are done being copied over by the user. This gets tricky when multiple users are dropping files simultaneously though. If the script is busy moving one file/set of files and a second user drops a file, that second user’s file will get skipped.
Overview of process:
User drops to FOLDER A
File finishes copying to FOLDER A
File is is moved to FOLDER B
I pieced the below script together but cant seem to get it to work. By using filesize we can determine if the file has copied all the way over or not. Help?
property DELAY_TIME_SECONDS : 5 -- How long to wait between checking file size.
on adding folder items to thisFolder after receiving theItems
repeat with f in theItems
set oldSize to 0
set newSize to -1
-- When newSize equals oldSize, it means the copy is complete because the size hasn't changed.
repeat while newSize is not equal to oldSize
-- Get the file size.
set oldSize to size of (info for f)
delay DELAY_TIME_SECONDS
-- Sample the size again after delay for comparison.
set newSize to size of (info for f)
end repeat
-- HERE BEGINS THE MOVING SPECIFIC STUFF
tell application "Finder"
try
set this_file to (item f of theItems)
set processFolder to alias "Macintosh_HD:Users:Shared:SHACKATTACK:process"
move this_file to processFolder
end try
end tell
-- HERE ENDS THE MOVING SPECIFIC STUFF
end repeat
end adding folder items to