Pass Files and Directories through AppleScript in Automator

Howdy guys!

The subject of this posting might be a little confusing so here is what I actually want to achieve:
I created an Automator workflow to upload a selected file or directory from Finder to my FTP server, using the “Get selected Finder items” and Transmit’s “Upload files” action.
Uploading worked pretty great with that configuration, but I wanted more! :wink:

I wanted the URL of the uploaded file to be on the clipboard, so that I can easily post it to chats etc.
I’m a complete newbie to AppleScript but somehow wrote the script below and put it between the Finder and the Transmit action.
The script extracts the filename from input and posts the URL to the clipboard. That works! :stuck_out_tongue:
The only problem is, that it’s output doesn’t seem to be the same as it’s input, so that Transmit doesn’t work anymore and isn’t uploading anything :frowning:

This is the code, any improvements are appreciated! :rolleyes:


on run {input, parameters}
	copy input to theSelected
	set outputPathList to {}
	repeat with anItem in theSelected
		set AppleScript's text item delimiters to {":"}
		copy last text item of (anItem as string) to end of outputPathList
	end repeat
	
	set AppleScript's text item delimiters to return
	set outputString to outputPathList as string
	set AppleScript's text item delimiters to ""
	
	set the clipboard to "http://pascal.foo/stuff/" & outputString
	
	return input
end run

Thank you!

Pascal

Hi Pascal,

two suggestions:

  1. in the script below you get a weird path result if you have more then one item in the variable input.
    This creates a path for each item and copies all paths to the clipboard
on run {input, parameters}
	set outputPathList to ""
	repeat with anItem in input
		set outputPathList to outputPathList & "http://pascal.foo/stuff/" & name of (info for (anItem as alias)) & return
	end repeat
	set the clipboard to outputPathList
	return input
end run
  1. If the Transmit action doesn’t work either, try to uplaod first and then run the script

Hi Stefan!

These are cool improvements, but they don’t solve the actual problem :frowning:
I can’t run the script after after Transmit, because that action doesn’t have any output.

Thank you so far

Pascal

Edit: Okay, ignore the stuff above, it IS possible to put the script after the Transmit action and it works! Thank you very much!