Use “Keep Both” to Merge Same Name Files into Single Folder of Mac OS X
The Mac Finder offers a variety of methods of merging two folders contents together into a single directory. One option allows users to join different directory contents together that contain files with the same names, using the ‘keep both’ function in Mac OS X Finder.
This can be a little confusing at first glance, but after a bit of practice you’ll understand a bit more how the feature works and how you can use it to merge directory contents with files that share the same names together into a single folder, entirely by using the Mac OS X Finder.
If you’re going to try this yourself, it’s strongly recommended to do so with unnecessary files or folders, and preferably make a backup beforehand. The reason is quite simple; you don’t want to accidentally replace essential files or folders while discovering how the “keep both” choice works and behaves.
How to Merge Files with the Same Name into a Single Folder in Mac Finder with ‘Keep Both’
In this example, let’s say you have two folders with contents that share the same name – but the files are different – like 0.png, 1.png, 2.png, etc, thus, you do not want to overwrite any files, you simply want them all to be in the same folder, thereby joining them together and merging the directories into one:
- Select all files from the source folder, then hold down the “Option / alt” key and drag and drop them into the destination folder (remember, the destination folder has files of the same name)
- You’ll get a message saying “An item named ‘file’ already exists in this location. Do you want to replace it with the one you’re moving?” – DO NOT choose Replace as it would overwrite the files
- Instead, assuming you held down the Option key (you can also hold it down after the fact), you’ll see a third option button “Keep Both” – choose this instead (optionally, check the “Apply to All” box if you’re confident you want to keep both of all files and don’t want to approve each one)
The Finder will move the source files into the destination folder and rename them automatically so they do not overwrite one another.
The naming convention is rather basic, it simply appends a counting number to the end of the files coming from the source. Using the aforementioned filename example, that means copying 0.png, 1.png, 2.png, etc into another folder with the same named files will rename them automatically to “0 2.png, 1 2.png. 2 2.png”, and so on.
Because of the naming convention of simply appending a number to the end of the source files being copied, perhaps a better option is to first batch rename the file contents of one folder, and then just drag and drop the newly renamed files into the other folder. In that case, because the file names are different, it will not triggering the ‘keep both’ option at all and the files would drop into the folder as you would moving any other items around. This is often preferable since you can choose the file names yourself rather than going with the naming convention that ‘keep both’ assigns to the files, but it’s really up to the Mac user to figure out what’s best for their situation.
It’s also worth pointing out that you can enable the “Keep Both” Option after the dialog box has been triggered for file copies. If you see a “Skip” option in the dialog instead, hold down the OPTION key to switch to to ‘Keep Both’ like so:
Note: The “Keep Both” choice only appears with identical named files in folders, if the file names are different, the button will not appear, and if you held the Option key it would simply copy the files into the other folder.
Admittedly, the way Finder handles this is a little confusing at first glance, but it works as advertised. For Mac users who are more advanced, turning to the command line and using ditto to copy files between directories is another excellent option, or even using ditto tomerge directories in Mac OS X.
And yes, there is a ‘merge’ option hidden in the Finder, but it’s behavior is sometimes even more peculiar than “Keep Both”, so we’ll focus on explaining that in another article.
What do you think? If you have any tips or tricks, share in the comments!