Folder Actions

Ok, so I have a folder actions setup that’s supposed to redirect all files that come into that folder of a certain type to a different folder. That part works fine, I just need to know how you figure out what files were added to the folder. My code is:

on adding folder items to this_folder
	try
		display dialog "JPG files will be forwarded to \"JPEG Files\"" with title "Finder" buttons {" Cancel ", " Ok "} default button 2
		set theResult to result
		if button returned of theResult = " Cancel " then
			set errLine to 0
			error
		end if
		repeat with i from 1 to (length of theDetectedItems)
			set theName to ((item i of theDetectedItems) as string)
			
			repeat
				set errLine to 5
				if ((offset of "." in theName) = 0) then exit repeat
				set theName to text ((offset of "." in theName) + 1) thru end of theName
			end repeat
			if theName = "ipa" then
				tell application "Finder"
					move file (item i of theDetectedItems) to folder (((path to desktop as string) & "JPG Files:") as alias)
				end tell
			end if
		end repeat
		try
			display dialog "File transfer success." with title "Finder" buttons {"Exit"} default button 1 giving up after 5
		end try
	on error
		if errLine = 0 then
			display dialog "File transfer canceled by user." with title "Finder" buttons {"Exit"} default button 1
		else
			--display dialog "File transfer canceled." with title "Error in code " buttons {"Exit"} default button 1
		end if
	end try
end adding folder items to

But theDetectedItems should be replaced with the variable that is whatever items were added. Anybody know what this variable is called?

Thanks!

PS: I looked in the Folder Actions Setup’s dictionary but it wasnt in there :frowning:

Hi,

just add the parameter after receiving


on adding folder items to this_folder after receiving addedItems

addedItems contains a list of alias specifiers

Ok, that worked great, thanks man! Also, do you know what wrong with this code:

set theName to "aFolder"
set theSpot to (path to downloads folder) as alias
tell application "Finder"
	make new folder at alias theSpot with properties {name:"j"}
end tell

I keep getting an error with something about integers, im confused, lol
Thanks

too many specifier keywords


set theSpot to path to downloads folder -- is always alias
tell application "Finder"
	make new folder at theSpot with properties {name:"j"}
end tel