How to Sync Files and Folders Outside Your Dropbox Folder with Automator (Mac)

In my post 8 Useful Dropbox Tips and Tricks, I explained how you can sync files and folders outside your Dropbox folder by creating symbolic links using the Dropbox Folder Sync addon. While this method did work, I didn’t find it ideal since it wouldn’t let me remove the symbolic link in any simple fashion lest I choose to delete the file or folder itself. Or, at least that’s what I experienced anyways.

Luckily, there is a far better way to sync files outside of Dropbox using the Mac program, Automator. Automator is this really neat program on the Mac that lets you automate many repetitive tasks for you. For example, you can create what are called “workflows” that can rename a large batch of files, or resize numerous images quickly.

In this tutorial, I will create a workflow using the Services template in Automator. Services are these custom context menu bar items you can add to almost any Mac program. This tutorial will show you how to create one that adds a “Sync with Dropbox” option to menu items so that you can easily right-click any file or folder and sync it with Dropbox.

Step 1: Select Services when Automator Launches

Step 2: Change the dropdown menu

After selecting the Services template, change the default dropdown menus so that it reads, “Services receives selected files or folders in Finder.”

Step 3: Use the search bar to add the “Run Applescript” action to the workflow


Simply type in the phrase until you see the name. Then, click and drag it over to your workflow.

Step 4: Replace the text in the Run Applescript window with the following code

on run {input, parameters}

        repeat with i from 1 to (count input)
                set posix_path to POSIX path of (item i of input)
                if posix_path ends with "/" then set posix_path to ¬
                        text 1 thru -2 of posix_path
                set AppleScript's text item delimiters to "/"
                set filesname to quoted form of text item -1 of posix_path
                do shell script "ln -s " & quoted form of posix_path ¬
                        & " " & "~/Dropbox/" & filesname
        end repeat

        return input
end run

This code creates the symbolic link between the file or folder and Dropbox. If your Dropbox folder is located somewhere different, make sure you change line 10 accordingly.

Step 5: Save the workflow and give it a name


Name it something like “Sync with Dropbox.” Now, whenever you right click on any file or folder, you will see a “Sync with Dropbox” menu item. Pretty sweet, eh?

Video!

Hat tip to the awesome people at LifeHacker for the great tip!

  • George Hill

    Hi, at step 4 it says change if your dropbox is located else where, i was wondering how do you change it ?

    • http://loneplacebo.com/about Tony Hue

      So, I’m assuming that you have your Dropbox folder in your Documents folder since that is the default location that Dropbox is installed unless you specify otherwise. In that case, line 10 should read:

      nښڮ֦r鞞?)n-jj_Wn

  • Adam

    Thanks!! Great tips!!

    May I know how do I rename/delete the workflow name that appeared in the right click menu?

  • Petete

    It does not work! Automator responses: Expected “given”, “with”, “without”, other parameter name, etc. but found “=”.

  • User

    remove the first and it will work

  • User

    remove the first and last lines and it will work (I think that those lines are BBCode!)

    • http://tonyhue.com Tony Hue

      Thanks for pointing that out. It was left over from a syntax higlighter plugin.