Mac OSX

How to sync two folders on macOS 

MacOS offers different methods to sync contents of two folders. The process comes handy when you want to keep copy or backup of files on an external drive. Similarly, folder sync also allows to keep mirror files inside macbook.

Third-party folder sync

Developers have created applications for folder sync purpose. These applications not only sync the content of chosen folders but also can set the sync interval. A sync interval is a useful option which allows you to restore files to a prior state in case of a mistake.

Sync Folders is a good utility with a simple interface. It allows you to perform two sided folders sync along with an option to select sync time interval. You can start the sync process and it’ll automatically take care of it based on the chosen interval.

Download Sync Folders

  • Once you’ve installed Sync Folders, click Start Sync Folders on first launch screen.
  • Under Folder A drag and drop the folder you want to sync from, and under Folder B add the folder you want as mirror.
  • Select Rules by clicking Sync Mode and there you’ll come across update rules between the two folders.
  • Click Settings and change Sync interval in order to select a custom update time.
  • Click Sync Current Task and the two folders will sync mutually based on Sync Mode rules. For example, A <-> B is the bidirectional tracing mode which will also trace deletions, on the contrary A <+> B is bidirectional tracing mode without tracing deletions, it’ll just add new files. The pro version has other options as well.
  • In the status bar, you can also turn on auto sync.
Folders Sync macOS
Folders Sync on macOS

Terminal for folder sync

You can also use macOS terminal for sake of syncing contents of two folder, however, this will depend on the following command:

  • rsync -aE –delete ~/SOURCE_FOLDER /DESTINATION_FOLDER
  • The -a option means archive mode which preserves file permission, symbolic links as well as copies files recursively.

In case of an external hard drive you’ll need to explore /Volumes folder and use the rsync command by proving external drive path in place of DESTINATION_FOLDER. Furthermore, this command will delete anything additional in the destination folder. Note that this isn’t two way sync process as compared with the third-party application.

You can automate the rsync command through automator and can also run the shell script with keyboard shortcut to initiate sync using a specific shortcut command. Let’s learn how you can combine three different sync commands in automator:

  • Open Automator and choose WorkFlow.
  • Search for Run Shell Script in the Actions. Under Options check Ignore this action’s input as we are not giving any input file.
  • Select Pass Input “as arguments” and delete any thing present. Write the rsync command as shown below. Here three folders are synced with other three folders in other locations.
  • Click File and select Save. Write the name of the script and then run it in order to perform the desired operations.
rsync command on automator
Automator and rsync command

Conclusion

You can either use third party applications for syncing the contents of two folders inside macOS or you can use rsync utility of terminal. Either way, the job is done. Additionally, you can also use automator to combine rsync command for multiple folders. On macOS syncing folders on an external drive provides you an option to keep backup of files in case of an emergency.