Easy Way to Sync Folders

I’ve been bad at keeping the actual productivity post to commentary post ratio high here. At the old blog the majority of my posts were about productivity and scripting. I’ve not had time the past couple of months to do this here. So here’s a tip I just gave to someone on Ars.

What’s the easiest way to sync a folder between your laptop and desktop? There are lots of ways to do this. I’ve found the simplest way is Dropbox. The problem is that Dropbox only syncs what’s in the Dropbox folder. However you can use symlinks to sync any arbitrary folder.

On your desktop do the following (assuming you already have Dropbox installed)

ln -s path/to/my/folder ~/Dropbox/folder

Now any change to the original folder will also be on Dropbox and will get synced.

On your laptop do something similar. (If you already have the folder there, change its name so it’s no overwrite)

ln -s ~/Dropbox/folder path/to/my/folder

Obviously change the paths and folder names to what you actually use.

To those of us who use the shell a lot this is obvious. To a lot of more causal users it’s the sort of thing they didn’t know they could do.

7 thoughts on “Easy Way to Sync Folders”

  1. Clark, this is a million-dollar tip! Thanks!

    Have you ever used something like this to sync either (a) sacred folders, like the Desktop folder, or (b) preferences files (I’ve love my Quicksilver preferences to sync, for instance)?

    1. I’ve not done that but it should be possible. With regards to preference files you can do it but there are some big gotchas. Most applications assume they have total application to those files. If you have multiple applications trying to sync different versions bad things will happen. So you can do it but then you have to pay attention to ensure only one copy of the app is running at a time or you are accessing only pref files that won’t cause troubles.

      Some applications can do this though. I’d have to check but I think BBEdit is setup in such a way to work with Dropbox for its preferences. But typically these want you not to use the symlink trick but specify the file. An other example of this is 1Password which will sync via Dropbox.

      The problem is that if the app isn’t written to deal with the complexities of this eventually you’ll get data corruption of your preferences. So if I did this I’d do it only on a file by file basis trying it out with particular applications.

      Typically the reason I do this is so that I can deal with certain directory structures but still sync via Dropbox.

      1. I get a ‘permission denied’ message from the Terminal when trying to do this to the Desktop, I guess because it would require me to overwrite the Desktop.

        1. Yeah, rename Desktop first to something like Desktop.bak then do the symlink, then copy the files out of ~/Desktop.bak to your new ~/Desktop.

  2. Clark, I hope I’m not bothering you with all these questions. I’m not able to rename my Desktop either in the Finder or in the Terminal. How do you rename yours?

Leave a Reply

Your email address will not be published. Required fields are marked *