I have written a script to upload files using a list via the CyberDuck ftp application.
the script, as is, works if i drop single or multiple files and uploads everything correctly. Here is the script.
on open these_items
repeat with i from 1 to the count of these_items
set this_item to item i of these_items
set the item_info to info for this_item
if (folder of the item_info is false) and (alias of the item_info is false) then
process_item(this_item)
end if
end repeat
end open
on process_item(this_item)
set theServer to "servername"
set theUser to "username"
set thePassword to "password"
set theProtocol to "ftp"
set chooseSite to choose from list {"Folder A", "Folder B"} with prompt "Where are you uploading the file(s) to?"
set chooseSite to the result as string
if chooseSite is "Folder A" then
set theUploadFolder to "FolderA/ads"
set the item_count to 1
if the item_count is greater than 0 then
with timeout of 300 seconds
tell application "Cyberduck(FTP)"
set theBrowser to make new browser
tell (theBrowser)
set encoding to "UTF-8"
connect to theServer with protocol theProtocol as user theUser with initial folder theUploadFolder with thePassword
upload file this_item
close theBrowser
end tell
end tell
end timeout
end if
end if
if chooseSite is "Folder B" then
set theUploadFolder to "FolderB"
set the item_count to 1
if the item_count is greater than 0 then
with timeout of 300 seconds
tell application "Cyberduck(FTP)"
set theBrowser to make new browser
tell (theBrowser)
set encoding to "UTF-8"
connect to theServer with protocol theProtocol as user theUser with initial folder theUploadFolder with thePassword
upload file this_item
close theBrowser
end tell
end tell
end timeout
end if
end if
end process_item
Now, I would think to make it be a folder action, I would have to modify it something along the line of this:
on adding folder items to this_folder after receiving these_items
set theServer to "servername"
set theUser to "username"
set thePassword to "password"
set theProtocol to "ftp"
set chooseSite to choose from list {"Folder A", "Folder B"} with prompt "Where are you uploading the file(s) to?"
set chooseSite to the result as string
if chooseSite is "Folder A" then
set theUploadFolder to "FolderA/ads"
set the item_count to 1
if the item_count is greater than 0 then
with timeout of 300 seconds
tell application "Cyberduck(FTP)"
set theBrowser to make new browser
tell (theBrowser)
set encoding to "UTF-8"
connect to theServer with protocol theProtocol as user theUser with initial folder theUploadFolder with thePassword
upload file this_item
close theBrowser
end tell
end tell
end timeout
end if
end if
if chooseSite is "Folder B" then
set theUploadFolder to "FolderB"
set the item_count to 1
if the item_count is greater than 0 then
with timeout of 300 seconds
tell application "Cyberduck(FTP)"
set theBrowser to make new browser
tell (theBrowser)
set encoding to "UTF-8"
connect to theServer with protocol theProtocol as user theUser with initial folder theUploadFolder with thePassword
upload file this_item
close theBrowser
end tell
end tell
end timeout
end if
end if
end adding folder items to
So when I drop a file in the folder where I setup this folder action script, it connects to the ftp folder, but does not upload anything… I think i’m missing where to define “this_item” could anyone possibly tell me how to do that… thanks a bunch!