Folder Action Trouble

Hello all.

I am haveing trouble with a folder action that is used to dynamically build pre-press files and set them up to be press-ready and send plates. But I am having trouble with the folder action that is used to proccess the tagged files.

Basically a website creates tagged text files that go to a folder that has the action script and it tells Indesign how to build the file. The only problem is if a file is already in the folder and another files is added before the first one is proccessed they merge or error out. Here is the script without the indesign part.

property idCR : "
"
property done_foldername : "Complete"
property failed_foldername : "Failed"
property originals_foldername : "Processed"
property email_foldername : "Emails"
property newimage_extension : "pdf"
property type_list : {"txt"}
property extension_list : {"txt"}


on adding folder items to this_folder after receiving these_items
	tell application "Finder"
		activate
		--sets up folder directory
		if not (exists folder done_foldername of this_folder) then
			make new folder at this_folder with properties {name:done_foldername}
		end if
		set the results_folder to (folder done_foldername of this_folder) as alias
		if not (exists folder originals_foldername of this_folder) then
			make new folder at this_folder with properties {name:originals_foldername}
			set current view of container window of this_folder to list view
		end if
		set the originals_folder to folder originals_foldername of this_folder
		if not (exists folder failed_foldername of this_folder) then
			make new folder at this_folder with properties {name:failed_foldername}
		end if
		set the failed_folder to (folder failed_foldername of this_folder) as alias
		if not (exists folder email_foldername of this_folder) then
			make new folder at this_folder with properties {name:email_foldername}
		end if
		set the email_folder to (folder email_foldername of this_folder) as alias
	end tell
		try
			repeat with i from 1 to number of items in these_items as string
				--display dialog these_items as string
				set this_item to item i of these_items as alias
				set the item_info to the info for this_item
				if (alias of the item_info is false and the file type of the item_info is in the type_list) or (the name extension of the item_info is in the extension_list) then
					tell application "Finder"
						activate
						my resolve_conflicts(this_item, originals_folder, "")
						set file_name to the name of this_item as string
						set the new_name to my resolve_conflicts(this_item, results_folder, newimage_extension)
						set the source_file to (move this_item to the originals_folder with replacing) as alias
					end tell
					process_item(source_file, results_folder, email_folder, failed_folder, file_name)
				end if
			end repeat
		on error error_message number error_number
			if the error_number is not -128 then
				tell application "Finder"
					activate
					display dialog error_message buttons {"Cancel"} default button 1 giving up after 120
				end tell
			end if
		end try
end adding folder items to
on resolve_conflicts(this_item, target_folder, new_extension)
	
	tell application "Finder"
		set the file_name to the name of this_item
		set file_extension to the name extension of this_item
		
		if the file_extension is "" then
			set the trimmed_name to the file_name
		else
			set the trimmed_name to text 1 thru -((length of file_extension) + 2) of the file_name
		end if
		if the new_extension is "" then
			set target_name to file_name
			set target_extension to file_extension
		else
			set target_extension to new_extension
			set target_name to (the trimmed_name & "." & target_extension) as string
		end if
		if (exists document file target_name of target_folder) then
			set the name_increment to 1
			repeat
				set the new_name to (the trimmed_name & "." & (name_increment as string) & "." & target_extension) as string
				if not (exists document file new_name of the target_folder) then
					-- rename to conflicting file
					set the name of document file target_name of the target_folder to the new_name
					exit repeat
				else
					set the name_increment to the name_increment + 1
				end if
			end repeat
		end if
	end tell
	return the target_name
end resolve_conflicts
-- this sub-routine processes files 
on process_item(source_file, results_folder, email_folder, failed_folder, file_name)
set "Blablabla" to blaBlabla
end process_item


Model: Powerbook G4 15’
AppleScript: Version 2.1.1 (81)
Browser: Safari 416.12
Operating System: Mac OS X (10.4)