use folder action to pass filename to application

Hi,

I’ve created an automator workflow, which if I control-click a file and select the workflow from the menu, uploads that file to an ftp server. I have saved this workflow as an application.

I also have a folder action set up:


on adding items to this_folder after receiving added_files
      --wait until the file finishes copying (folder size stops changing)
      repeat
           set x to (info for this_folder with size)
           delay 2
           set y to (info for this_folder with size)
           if x = y then exit repeat
      end repeat  

      --here is where I would like to pass the file (which just finished copying into this folder) over to the automator application

      tell application "my upload application"
            launch
      end tell
end adding folder items to


the desired effect being… drag a file into a folder, and it gets uploaded to an ftp server…

Can anyone help?

many thanks in advance!
Dave

What’s about a droplet instead, I use a similar one

property serverPath : "[url=ftp://ftp.myserver.com/myFolder/]ftp.myserver.com/myFolder/[/url]"
property user_name : "user"
property pass_word : "¢¢¢¢"

on open these_items
	repeat with oneItem in these_items
		do shell script "curl  " & quoted form of serverPath & " -u " & user_name & ":" & pass_word & " -T " & quoted form of POSIX path of oneItem
		tell application "Finder" to delete oneItem
	end repeat
end open

save it as an application and drag it to the toolbar of some Finder window next to the search field

Hi Stefan,

I’m not sure if a droplet will work for me, since this is just one stage in a larger automated process… I did modify your script a little to try it as a folder action :



on adding folder items to this_folder after receiving added_files
	
	repeat
		set x to (info for this_folder with size)
		delay 2
		set y to (info for this_folder with size)
		if x = y then exit repeat
	end repeat
	
	set serverPath to "ftpservername.com"
	set user_name to "myusername"
	set pass_word to "mypassword"
	
	repeat with oneItem in added_files
		do shell script "curl " & quoted form of serverPath & " -u " & user_name & ":" & pass_word & " -T " & quoted form of POSIX path of oneItem
	end repeat
	
end adding folder items to

Curl originally failed because the password has an @ symbol in it (I tried escaping it with a backslash but it didn’t help), however after trying a different account and password, I got a different error “curl: (56) FTP response reading failed.”

Any ideas?

Thanks
Dave

No idea,

I’ve just run the script with my server data and it worked fine

Thanks for testing it out… I’ll see if I can track down the problem over here.

regards,
Dave

Stefan- I finally got it working with curl- it was a problem with the server and permissions.

Thanks again for your help!
Dave