What It Does

AutoFileUpload automatically uploads any files dropped into specified folders to a remote computer. This means you can drag and drop files to a remote computer while working in the Finder -- no need to open up a file transfer program, no need to type passwords or log in -- in short, it is a local "drop box" for your remote computer that works transparently with the Finder.

How It Works

AutoFileUpload is an AppleScript application that is attached to a folder in the Finder via Folder Actions. When files are dropped in the folder, the script is triggered, which transfers the files to the remote machine using the scp command.

How To Install

  1. The AutoFileUpload script must be installed on your computer. You can download the AutoFileUpload.scpt executable script (12kb) (download with "Save As"), or you can create your own script document in Script Editor, insert the code below, and save it.
  2. You must have SSH public key support to be able to run scp to connect securely to the remote system. All Mac OS X, Linux, and other Unix systems support ssh and scp without extra software, though you need to configure your public key access for your account. If you do not know how to do this, I suggest you use a tool like SSH Agent or Secure Shell Helper. If you want to learn more or configure things manually, look at SSH Public-Key Authentication (at O'Reilly), Basic SSH Setup instructions, or SSH HOWTO.
  3. Edit the script (by double-clicking on it if it is not already open in Script Editor) to be customized with your account name, remote host name, and remote directory you want files to be copied to. If you do not set these up, you will be prompted for each missing setting when the script runs.
  4. You must create a Folder Action to trigger the script. Select the folder you wish to use as a drop folder (creating it if necessary -- I did so on my Desktop), access the contextual menu (by control-clicking on the folder's Finder icon), select Attach a Folder Action..., and select the AutoFileUpload script you installed.

How To Use

  1. Drag and drop a file or folder in the folder you activated during installation, and it will get transmitted to the remote server.
  2. Files and folders that have been transmitted will be placed in the folder named Done in your local drop folder.
  3. Once files get moved to the Done folder, you should move them to their permanent location if you want to keep them, or delete them. To avoid accidentally deleting something I wanted to keep locally, I usually copy it to the drop folder (by option-dragging it) rather than move it as described in Step 1, so I know nothing in the drop or Done folder is an original that needs to be saved.

Note: At the moment the existence of the remote directory and/or file is not verified. This means that a file will overwrite any previously existing remote file of the same name. Also, a file to be transferred to a directory name that is non-existent on the remote host will somewhat non-intuitively be renamed to that name (the directory won't be created automatically).

AutoFileUpload program text

-- AutoFileUpload - automatically transfer files from the Finder to a remote server
-- Copyright (C) 2004 John F. Whitehead
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 2
-- of the License, or (at your option) any later version.
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- GNU General Public License for more details.
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-- The GNU GPL is available at <>.
-- AutoFileUpload, version 1.0, 23 Sep 2004
-- Documentation available at <>.

-- customize these three variables for your remote account info
-- or leave any at their default values to cause you to be prompted each time
-- or customize them all and create multiple versions of this script for each destination
property remote_user : "username" -- default: "username"
property remote_host : "hostname" -- default: "username"
property remote_dir : "~" -- default: "~" (home directory)

-- nothing below here needs to be changed

property verbose : false -- change to true for verbose debugging messages

on adding folder items to this_folder after receiving these_items

    repeat while (remote_user is "username")
        display dialog "Please specify the username for the remote host (you may set this permanently by editing the script):" default answer remote_user buttons ["Cancel", "OK"] default button 2
        set remote_user to text returned of result
        if (remote_user = "") then
            set remote_user to "username"
        end if
    end repeat
    repeat while (remote_host is "hostname")
        display dialog "Please specify the address of the remote host for " & remote_user & " (you may set this permanently by editing the script):" default answer remote_host buttons ["Cancel", "OK"] default button 2
        set remote_host to text returned of result
        if (remote_host = "") then
            set remote_host to "hostname"
        end if
    end repeat
    display dialog "Please specify the remote directory for " & remote_user & "@" & remote_host & " (you may set this permanently by editing the script):" default answer remote_dir buttons ["Cancel", "OK"] default button 2
    set remote_dir to text returned of result
    -- empty dir should be same as home dir
    if (remote_dir = "") then
        set remote_dir to "~"
    end if

    set remote_path to remote_user & "@" & remote_host & ":" & remote_dir & "/"
    if verbose is true then
        display dialog "remote path is " & remote_user & "@" & remote_host & ":" & remote_dir & "/"
    end if

    tell application "Finder"
        if not (exists folder "Done" of this_folder) then
            make new folder at this_folder with properties {name:"Done"}
        end if
        set the done_folder to folder "Done" of this_folder as alias
    end tell

    repeat with i from 1 to number of items in these_items
        set this_item to item i of these_items
        set the item_info to info for this_item
        if this_item is not the done_folder then
            set the item_path to the quoted form of the POSIX path of this_item
                if verbose is true then
                    display dialog "scp -p -q -r " & item_path & " " & remote_path
                end if
                do shell script "scp -p -q -r " & item_path & " " & remote_path
                tell application "Finder"
                        move this_item to done_folder
                    on error err_msg
                        display dialog "Could not move '" & this_item & "': " & err_msg as string buttons "OK"
                    end try
                end tell
            on error err_msg
                display dialog "Could not scp '" & item_path & "': " & err_msg as string buttons "OK"
            end try
        end if
    end repeat

end adding folder items to

Release Notes

AutoFileUpload 1.0 was released on 23 September 2004.