Get compressor to upload to ftp once finished

This is something I have been going back and forth on for quite some time. I love the idea of a drag and drop upload to ftp. I absolutely hate the idea of having to hard code the ftp password into a piece of applescript. If that script accidentally ends up in the wrong hands then your server is compromised. A co worker recently suggested I look into using bookmarks from within fetch, and it works great! This way fetch keeps your password in the osx keychain and the applescript only has to know the name of the bookmark (they are called shortcuts in fetch) to call it.

Actually, this post has two different was of accomplishing the same goal. The simplest way is to create a shortcut in fetch and then create a droplet from it. Here is a page describing how to do that. Short version: command-S.

The more advanced way to do it is the script below. As it stands it offers almost the exact same thing as the droplet, but it is written in applescript, so you have room to tweak things. Would you like to add a folder with todays date to the directory? Copy the link into the clipboard and open in a web browser? There are a million possibilities, you just have to get your hands dirty.


If you really want to start automating things then you can create a folder with one version of this script for each directory / server that you may upload to and then you can select the appropriate script from the last tab in the compressor inspector window. Heck, if you do one upload frequently enough then go ahead and save that compressor / applescript combo as a droplet and put it in your dock!

The original code came from proactive interactive. But I have made some tweaks for security and to allow you to open the app to select files as well as drag files on top of the app.

You can read the code below, but if you are going to copy and paste it, do that from here as wordpress does a weird thing with quotation marks.

on open (thefiles)
(*There should only be one file, but just in case send it through a loop*)
repeat with thefile in thefiles
FetchUploadFile(thefile)
end repeat
end open

on FetchUploadFile(thefile)
set shortcut_name to "yourshortcutname.com"
(*change the above to your shortcut name*)
with timeout of 60000 seconds
try
tell application "Fetch"
activate
open shortcut shortcut_name
put into front transfer window item thefile
end tell
on error
display dialog "error uploading " & thefile
end try
end timeout
end FetchUploadFile

on run
choose file with prompt "Select file(s) to upload:" with multiple selections allowed
open (result)
end run

By tweaking the shortcuts in fetch you can select different servers and starting directories. Create one shortcut for each project and export one applescript app with each shortcut.

This script will also work outside of compressor. Drag and drop a file onto the app to start an upload, or double click it to bring up a “select files to upload” dialog box.

Side note: while I was researching this I came across a cool widget for transmit. It does the same thing as this app, but it lives with your widgets and may or not be accessible from to compressor post processing window.

~ by ross on January 22, 2010.

11 Responses to “Get compressor to upload to ftp once finished”

  1. I’m having trouble getting this to work. I usually use Cyberduck to upload, but have downloaded fetch, created a shortcut, saved it as a droplet and can’t get the code to work.

    Begin Code:

    on open (thefiles)
    repeat with thefile in thefiles
    FetchUploadFile(thefile)
    end repeat
    end open

    on FetchUploadFile(thefile)
    set shortcut_name to “REMOVEDMYSITE”
    with timeout of 60000 seconds
    try
    tell application “Fetch”
    activate
    open shortcut shortcut_name
    put into front transfer window item thefile
    end tell
    on error
    display dialog “error uploading” & thefile
    end try
    end timeout
    end FetchUploadFile

    on run
    choose file with prompt “Select file(s) to upload:” with multiple selections allowed
    open (result)
    end run

    Thanks for any help!

  2. Hi Scott.
    Your code looks good, so I don’t know where things are going wrong. What kind of errors are you getting? Does it do anything? Does the fetch shortcut work by itself? You also don’t need both a droplet and the shortcut if you are running the applescript. You only need the shortcut for that. I would double check to make sure that the shortcut_name is the shortcut name, not the droplet name.

    Also, try trimming it down and see if you can get it to work in parts. i.e. try pasting this into script editor and running it. (i’m not sure if it will compile as-is, you might need to tweak it)

    set shortcut_name to “REMOVEDMYSITE”
    with timeout of 60000 seconds
    try
    tell application “Fetch”
    activate
    open shortcut shortcut_name
    end tell
    end try

    That script should open up the shortcut in fetch and then do nothing. If that works, then try checking the other parts. Let me know what you find!

  3. I pasted in the code, tried to compile and run and it said

    Syntax Error
    Expected expression but found unknown token.

    Thanks for your help Ross!

  4. Hey scott,
    The answer is weird, but the quotes used on wordpress aren’t the same as in applescript! look above the quoted code and I updated the post to a link you can use.

  5. Thanks Ross! I got it to work, I also wasn’t saving the applescript as an app.

    Now I’m trying to adapt it for use with Cyberduck instead of Fetch.

    Thanks again

  6. weird you should do that – I wrote this first for cyberduck!
    I’ll see if I can find the old code. It wasn’t excruciating, but it wasn’t nearly as easy as with fetch.

  7. I guess I’ll stick with Fetch then, the interface is much improved from when I last used it.

  8. The problem with using cyberduck was that there wasn’t an easy way to make a bookmark, so I had to bake the login and password into the script. That makes for a sticky situation. But if you want to use cyberduck don’t let me stop you, maybe you can figure it out where I couldn’t!

  9. HI, it feels crazy that this has just come up for me and a quick whip round google and it’s here!
    i am trying to automate this function at the moment. Would really appreciate some help though – am using cyberduck and and the office won’t shell out the measly 30 bucks for fetch. Also never written an applescript before but would love to make my life that bit easier. Is there any chance you still have that original script for cyberduck? i understand the concerns over security – but this is purely for uploading episodes to blip.tv and not my work server so i’m less concerned. tried editing the original script from Proactive Interactive with no success so any/all help would really be appreciated.
    cheers in advance,
    Pete

  10. How is this different from using your FTP site as a destination in Compressor?

  11. Hey Mat! This isn’t that different, except that I’ve never had good luck with ftp as a destination working consistently. One other benefit is that it allows you to perform multiple actions through scripting.

Comments are closed.