Folder action scripts

I’m having some trouble with this folder action script which must ZIP files dropped into a folder and it works somehow but then the dropped items are ZIPped twice I guess because of a temp file while the original is been zipped that doesn’t bothers me that much but the second zipped file replaces the first one and it have a lot of useless folders inside� lets say I ZIP a file, if I stop the process after the first zip, then when I unzip it I get only the file I wanted to zip but if I let the script finish the final ZIP looks like this "/users/Me/Desktop/folder/my_file"�

on adding folder items to this_folder after receiving these_items
	tell application "Finder" to set the source_folder to this_folder as alias
	set the item_list to list folder source_folder without invisibles
	set source_folder to source_folder as string
	repeat with i from 1 to number of items in the item_list
		set this_item to item i of the item_list
		set this_item to (source_folder & this_item) as alias
		set this_info to info for this_item
		set the current_name to the name of this_info
		if the current_name contains "sitx" then
		else
			if the current_name contains "zip" then
			else
				if the current_name contains "sit" then
				else
					tell application "Terminal"
						activate
						do script "cd" & " " & quoted form of POSIX path of this_folder & return & "zip -r -b /tmp" & " " & "./" & current_name & ".zip" & " " & current_name
					end tell
					set alert_message to "Delete Originals?"
					display dialog the alert_message buttons {"Yes", "No"} default button 2 with icon 2
					set the user_choice to the button returned of the result
					
					if user_choice is "Yes" then
						tell application "Finder"
							delete item current_name of folder this_folder
							quit application "Terminal"
						end tell
					end if
				end if
			end if
		end if
	end repeat
end adding folder items to

I was doing this with a folder action using DropStuff but it takes a lot of time to do the job while DropStuff opens, etc.

Hope someone can help :slight_smile:

Thanks!!

If you have an “on adding folder items” folder action, then any change to files in the folder (e.g., renaming, etc.) can set off the script. Putting a sub-folder in your folder action folder named something like “Zipped Files” and having the zip file created to that folder instead of your folder action folder may fix the problem.