Duplicating with a folder action

I am trying to build a Folder Action that would move an .eps file to another folder. The problem is, its not moving it. Here is what im working with so far:

on adding folder items to this_folder after receiving these_items
	repeat with i from 1 to the count of these_items
		set this_item to (item i of these_items as alias)
		set item_info to info for this_item
		set epsFolder to "Macintosh HD:Users:Joshb:Public:PDF:eps:" as alias
		set epsDirectory to POSIX path of the epsFolder
		set epsFolder2 to choose folder
		if name extension of the item_info is "eps" then
			display dialog "EPS File"
			--move this_item to epsFolder with replacing
			--move this_item to epsDirectory with replacing
			--move this_item to epsFolder2 with replacing
		end if
	end repeat
end adding folder items to

As the code is right now, it will successfully show me the display dialog “EPS File”. If i comment that out, and uncomment any of the three move statements below it, nothing happens.

I have built a very simple script to duplicate and that works fine, so im sorta at a loss as to why this isnt working.
Thanks for any help!


Hi josh,

try this

on adding folder items to this_folder after receiving these_items
	repeat with this_item in these_items
		set epsFolder to ((path to public folder) as string) & "PDF:eps:" as alias
		if name extension of (info for this_item) is "eps" then move this_item to epsFolder with replacing
	end repeat
end adding folder items to

Notes: these_items is a list of aliases so it’s no need to coerce the single items to an alias.
POSIX path doesn’t work in AppleScript, but you need it in the argument of the do shell script command

Edit: I’m amazed that this works without a Finder tell block

Ah thanks a bunch!

I tried incorporating what you posted into my current script, but it didnt work, so I tried the exact script you posted and it works fine.

Thanks again!

Move and duplicate are both verbs in Standard Additions, Stefan. Also the “set epsFolder…” statement doesn’t have to be inside the repeat - it can precede it. :wink:

Thanks, Adam, I’m still confused about the different behavior of certain terms within or outside a tell block e.g. an alias

Of course :wink:

Perfectly understandable – so am I; I usually try alias except when I know that something like choose folder or on adding items will deliver one anyway.

So do I :slight_smile:

Otherwise: RTFD, though the dictionaries are lying often :wink: