I have a folder on Drive 1 called Music, and it is 100GB. I have a folder on Drive 2 called Music, and it is 116GB. It's the most updated version. How do I copy the Music folder from Drive 2 to Drive 1 without having to rewrite every single file?

  • Which version of OS X are you using? – Nix May 13 '12 at 21:59
  • 1
    I am using 10.7.4. When I copy the folder from one drive to the other, I'm asked if I want to replace. No merge option. – dallen May 13 '12 at 22:02

The merge option will only show up if you are copying (rather than moving) the folder. Make sure you hold option while you drag the new folder to the location of the old folder. Alternatively, using +c to copy the new folder and +v to paste over the old folder should give you the option to merge the files.

  • This still seems to write over files that don't need to be rewritten. Using rsync instead – BRogers Mar 9 '16 at 2:44
  • Even if option to merge is available it sometimes does not work (just reports an error and do nothing) - especially in case of big folders as in your case. It's another reason why you should use rsync. – Andrzej Martyna Jan 13 '17 at 11:17

This is a classic use case for rsync:

rsync -av /source-path/source-dir /destination-path

rsync will copy only new and changed files to the new location.

It is important to understand how a trailing slash on the source argument functions. If there is a trailing slash then the contents of /source-path/source-dir will be copied to destination-path. If there is no trailing slash then source-dir itself will be copied to the destination and its contents will be another level down in the destination hierarchy.

So if you want to replicate one path to another include the trailing slash as follows:

rsync -av /sourcepath/sourcedir/ /duplicatpath/sourcedir/
  • 1
    Great catch! And if you're doing this from multiple drives (or anywhere on your computer) and don't want to type out the directories you can just drag a drive (external usb, or time capsule) or just a specific directory and have it add it to the command for you. Just drag the target location into terminal – BRogers Mar 9 '16 at 2:46
  • Man, thank you so much for suggesting the trailing slash. I've spent ours pondering why rsync -av ./foo/bar /vol1/foo/bar was copying over all existing files. Bloody slashes lol!!! – sming Aug 11 '16 at 14:31

Check the cp command. Use man cp and read the options. You can do something like:

cp -r -u ~/source ~/destination

-R, -r, --recursive : copy directories recursively
-u, --update : copy only when the SOURCE file is newer than the destination file or when the destination file is missing
-p same as --preserve=mode,ownership,timestamps
-v --verbose : explain what is being done

So if you want to copy files from you Downloads/music folder to say your Music/new folder you would do something as:
cp -ruvp ~/Downloads/music/* ~/Music/new/
This would merge the contents of these two folders and if two files with the same name and path exist it would keep the newest one based on the timestamp.

  • Are you sure the -u option works with the cp command in OSX? I'm getting the message "cp: illegal option -- u" in Sierra. It seems not all commands are the same as in Linux. – OMA Jul 24 '17 at 21:08
  • Try the cp --help command and see if the option is available. Or check the cp --version and make sure it is up to date. I am using : cp (GNU coreutils) 8.27 – drew7721 Jul 26 '17 at 14:35
  • Sadly, -u is not a valid flag for cp on OS X. It would be very convenient to have! – Per Quested Aronsson Aug 26 '17 at 21:27

Not sure why the default Lion Merge button doesn't show up for me. But I ended up using ditto. Found here: https://superuser.com/a/221599/102789

  • 1
    BE CAREFUL! ditto does not keep newer files, it always overwrites destination with source. If source file is older, it will zap away the new file and replace with older file – FrancescoMM May 18 '16 at 15:55
  • that's right - very important warning from FrancescoMM, use rsync – Andrzej Martyna Jan 13 '17 at 11:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .