Copy and move

Hello:
I need to be able to have a “hot folder” that when a file hits the folder it wants to make the PDF do two things: copy to a different volume on another network and then move to a different local folder. The copy to the network volume presents a little problem in that it is the hot folder for someone else’s script. If I just do a manual copy to this folder from the finder, it will try and move all the PDFs at one time and by the time the last of the batch is done copying, the script on the other end jumped the gun and tries to move it before the copy is done and it corrupts the file.

How do I get the copy and or move function to just do one file at a time? I’d love to be able to copy one file and then when done copy other and then another, etc.

For my move function, I have a script that will move the file to one of many different folders based on the suffix of the PDF. That piece seems to work pretty well.

So, I was thinking I would like to have one big drop folder.
It would copy any file with a green label applied to it to the network volume one at a time.
(Files that weren’t green should go to one error folder and a file that has a prefix of 000_ should fail, but all other prefixes are acceptable)
When the copy was complete it should move it to another drop folder.
That one would activate my sorting script and move it to a folder based on my suffix naming convention.

Does this cound logical and how can I keep the copy or duplicate function from trying to grab too many files at a time.

Thanks,

-curtis7137

I hope I am understanding that all files will have a 3 digit prefix of “000_” format.
If not, put a try statement around this line - set thePrefix to my getTextBefore(fileName, “_”)

Otherwise, I just tested this with folders on my desktop and it worked. May need a delay
or two depending on copy time of items.

property serverFolderName : (path to desktop as string) & "ServerFolder:" --change these accordingly
property localFolderName : (path to desktop as string) & "LocalFolder:"
property failedFilesFolder : (path to desktop as string) & "FailedFolder:"

on adding folder items to this_folder after receiving these_items
	if (count of these_items) > 0 then
		try
			tell application "Finder"
				repeat with eachitem in these_items
					set fileName to name of eachitem
					--get label index
					set labelColor to get label index of eachitem
					--get prefix
					set thePrefix to my getTextBefore(fileName, "_")
					if labelColor = 6 then
						duplicate file eachitem to alias serverFolderName with replacing
						move file eachitem to alias localFolderName with replacing
					else if thePrefix = "000" then
						move file eachitem to alias failedFilesFolder with replacing
					else
						move file eachitem to alias localFolderName with replacing
					end if
				end repeat
			end tell
		on error m number n
			display dialog m & return & n
		end try
	end if
end adding folder items to


on getTextBefore(whichText, delimiter)
	set oldDelims to AppleScript's text item delimiters
	set AppleScript's text item delimiters to delimiter
	set output to text item 1 of whichText
	set AppleScript's text item delimiters to oldDelims
	return output
end getTextBefore

Regards,

Craig