I’m a programmer, but I’m going to need help with this one… I spent some time looking at Apple’s AS documentation but it’s a very broad subject so here goes…
on adding folder items to this_folder after receiving added_item
try
tell application "Transmit"
if (connect to "[url=ftp://ftp.000.com]ftp.000.com[/url]" as user "uuu" with password "ppp") then
if (set your stuff to "/Users/uuu/Pictures/going_up/") then
if (set their stuff to "/000.com/gone_up") then
upload item "/Users/uuu/Pictures/going_up/added_item"
What do I do to get AS to parse added_item as the file name, not as the literal?
added_item is the file that’s dropped in the folder (first line of the Code I provided), and it’s the file I want to upload (last line of the Code). Say it’s ‘bob.gif’
I want to upload bob.gif, so I need to get ‘bob.gif’ into that upload path somehow. Like:
on adding folder items to this_folder after receiving added_item
try
set strNewItem to the added_item as string
tell application "Transmit"
if (connect to "[url=ftp://ftp.000.com]ftp.000.com[/url]" as user "uuu" with password "ppp") then
if (set your stuff to "/Users/uuu/Pictures/going_up/") then
if (set their stuff to "/000.com/gone_up") then
upload item strNewItem
I’m no expert, but it looks to me that you need first to put the path of this new item in a string, and the tell transmit to upload the item (string).
Hope it helps
OK. This all depends on Transmit’s dictionary. Can you post the relevant part of the dictionary (the section for upload item)?
It looks like added_item is an alias. In that case, it is a complete reference to the file you wish to upload. A typical upload command needs 5 things: username, password, the remote server, the directory on that remote server, and the local file’s complete location
I only see one thing there. Perhaps you’ve already scripted the first 4 things, and only need to to Transmit what to send? If the upload item command does not take a full alias, perhaps you need to get the parent folder of the item, have Transmit go to that folder, then choose just the file name? That sounds like a horrible way to script the GUI. Maybe Transmit has a command that does the whole thing in one shot. Could u post the dictionary here for us to help?
on adding folder items to this_folder after receiving added_item
try
tell application "Transmit"
if (connect to "[url=ftp://ftp.000.com]ftp.000.com[/url]" as user "uuu" with password "ppp") then
if (set your stuff to "/Users/uuu/Pictures/going_up/") then
if (set their stuff to "/000.com/gone_up") then
upload item "/Users/uuu/Pictures/going_up/added_item"
Maybe this will work.
on adding folder items to this_folder after receiving added_item
try
tell application "Transmit"
if (connect to "[url=ftp://ftp.000.com]ftp.000.com[/url]" as user "uuu" with password "ppp") then
if (set your stuff to "/Users/uuu/Pictures/going_up/") then
if (set their stuff to "/000.com/gone_up") then
upload item (posix path of added_item)
Krioni, here’s the Transmit dictionary entry for upload.
upload: Upload a file or folder
upload reference -- the object for the command
item Unicode text -- The path of the file/folder you want to upload.
Result: boolean -- the reply for the command
Wow. That’s an amazingly unclear dictionary. It looks the command should be something like:
upload SOME_OBJECT item SOME_FILE_OR_FOLDER
Unfortunately, that doesn’t make sense. It looks like you’re supposed to reference the desired file to upload twice.
Maybe “reference” is the thing to upload, and Unicode text is the path it should be uploaded to. In that case, it would look like this:
upload SOME_FILE_REF item “/public_html/files”
if you wanted to upload the file to /public_html/files
Maybe the developers of Transmit have some sample code? It might be helpful to write to them and ask them to explain the dictionary, and suggest they make it more clear. Is “The path of the file/folder you want to upload.” the CURRENT path to the file locally, or the DESIRED location for the upload. They don’t say. I’d guess it is the latter, since you usually are supposed to refer to local files by an alias or file reference for Mac programs.
Yes, the dictionary sucks throughout! I’ve communicated with Panic and they have made a couple of sample scripts availabe from their web site. They also said that they would consider working on the dictionary but I won’t hold my breath while waiting on it to happen.
According to their sample script, the upload line that I submitted above should work.
I just checked the latest release of Transmit (version 2.5) and, while they have added a new AppleScript command (list files), they have not done any work on the dictionary to make it less vague. It’s sad - Transmit deserves better treatment.