I’ve been doing some backups and cleaning up my system. I was struggling to figure out how to sync two folders on a Mac. Here you go – I tried the tools that are out there. They all seemed to be crappy. There is an easier way.
There aren’t any really good tools out there to help sync Mac folders between two local folders. I wish there was a cool fun interface. I’ve tried a couple of tools such as syncTwoFolders. They were just generating errors with a very unclear and odd UI. Sorry I just didn’t dig it. All my searches online for syncing never found what I was actually looking for. The tools out there are just not that good.
Somehow I found a site that was only talking about a terminal way of doing it. I gave it a try. It worked so easy and great to my sanguine. I surmised it would be worth mentioning it here.
There are many features in the Terminal command but no need to go to deep into it. The most common tasks would be to sync between two folders. One would be to replace older files without deleting files that are not in the origin. The other is to replace files and delete files that are not in the origin (as if you delete some of the files and don’t want them back). I know I’ll forget this command in a week. I know I’ll need it again. I’m pasting it here. I hope others find use for it as well.
You will need to use terminal. Change the source folder and destination folders.
rsync -vur --exclude=*.db --exclude=*.info /sourceFolder /destinationFolder
Really nice and easy. It only copy/update files. It does not delete anything in the destination folder. If you want to delete missing files in the destination folder just add this into the code:
rsync -vur --delete --exclude=*.db --exclude=*.info /sourceFolder /destinationFolder
Hope this helped you sync folders on Mac OS! I know it is helping me now.
If you need a step-by-step guide:
- In your Spot light type “terminal” enter terminal
- It doesn’t mater where it opens it just type :
- If there are files you want to exclude you can list them out (for example all your .svn files can be a good example) in our case we wanted to exclude 2 file types:
- If you want to delete the files in the destination you can add this code as well:
- Add the origin folder (the folder from witch you want to copy/sync) – the best way to do this is to drag the folder into terminal the folder path will output
- Add the destination folder path (same deal as before)
That’s about it. Take a look below for a full example (don’t forget to put the space where it needs to be and just be very careful not to delete something you didn’t intend to delete).
P.S. – a good tip to get your folder without writing the name is to drag the folder into terminal it will output the path of the folder for you.