X

Send us a Topic or Tip

Have a suggestion for the blog? Perhaps a topic you'd like us to write about? If so, we'd love to hear from you! Fancy yourself a writer and have a tech tip, handy computer trick, or "how to" to share? Let us know what you'd like to contribute!

Thanks for reaching out!
merging folders

Merging Folders in macOS

Although I’ve been using Macs since late 1984, I still find features in the operating system that surprise me. Recently I discovered that there is a merge function in macOS that makes it simple to merge the content of two folders. See how this tip works to make your file and folder organization a lot easier.


The old way

Here I have two folders that I want to merge. As you can see, some of the files inside both folders are the same, some are different, and some have the same name but different times associated with them. If I wanted to spend some time going through each folder and checking out the file names and times, I could create a temporary folder and do this manually.

Folders macOS Finder
Contents of two folders in the macOS Finder

That would mean just dragging one copy of the identical files to the temporary folder, getting the newer of the text files and dragging them to the temp folder, and then dragging the unique files in the folders to the temp space. This probably isn’t a bad idea with a couple of folders with few files. But what if you have hundreds of files in each folder?

If I wanted to copy all of the files from Folder 2 into Folder 1, I’d select the Folder 2 files, then drag them over to Folder 1 and drop them. Immediately I’d see a dialog telling me that one of the files already exists in Folder 1…

File replace dialog macOS Finder
The dialog informing us that a file already exists in the destination folder

Skip it?

At this point, I could click on the Skip button, in which case the duplicate file wouldn’t be copied. Immediately, the same dialog would appear for “Keynote-Photo-Collage-2.jpg,” and I’d need to click Skip again. Alternatively, I could check the Apply to All box, which would skip copying any files with identical names. That would also skip copying the Test1 and Test 2 text files, which are not identical, as they have different time stamps.

Clicking Stop interrupts the entire file copy process, which isn’t what I want to do. Replace replaces files with identical file names in Folder 1 with files from Folder 2. This isn’t going to help matters. Because one of the files in Folder 2 is older than the one in Folder 1, we wouldn’t want that file to replace it.

So you see the dilemma. It appears that we either need to manually merge the folders, or click a lot of dialog buttons. But there is another solution!


Merging folders

Here’s the trick that I didn’t know about until a few weeks ago. There is a special way to merge folders that doesn’t copy identical files, and always keeps the newer version of files with the same file name. The trick? Both folders need to have the same name.

Of course, if I’m in Finder and I try to name a folder the same as another one, a dialog tells me that that folder name is already taken:

Folder naming dialog
This dialog that appears when we try to change a folder name to an existing name.

The trick? The Option key

The workaround is this: Create a temporary folder and drag Folder 1 into it. Now give Folder 2 the new name Folder 1. To merge the folders, hold down the Option key before dragging Folder 2 (now called Folder 1) to the temporary folder. A dialog we haven’t seen before appears:

Merging Folders
Merge combines two folders with the same name, preserving new items.

See the Merge button? If we click it, then the contents of both folders are merged into one “Folder 1.” If there are individual files that are newer than their counterparts in the other folder, they are copied or stay in the combined folder.

Looking in the temporary folder (which kept the original name of “untitled folder”), we now see the merged Folder 1:

Merging folders
The merged folders

You can see that we have only one copy of each file from both folders in the merged folder, and the two test text files are the newest version from either folder.


How to avoid making a temporary folder

There is a way to avoid making a temporary folder to merge a couple of folders with the same name. You simply put one of them on another Mac volume. This can be an external drive, a flash drive, or a server.

After making sure that the folders have the same name on both Mac volumes, hold down the Option key, and drag the one folder onto the other volume. As long as macOS Finder sees two folders with the same name and they’re both going to be in the same volume, you’ll see the Merge button.


The Rocket Yard is filled with thousands of articles to answer your questions or stimulate creativity. You may find these articles to be helpful:

Steve Sande
the authorSteve Sande
Contributing Author
Steve has been writing about Apple products since 1986, starting on a bulletin board system, creating the first of his many Apple-related websites in 1994, joining the staff of The Unofficial Apple Weblog in 2008, and founding Apple World Today in 2015. He’s semi-retired, loves to camp and take photos, and is an FAA-licensed drone pilot.
Be Sociable, Share This Post!

Leave a Reply

Comment

Name

2 Comments

  • Finder will not present the “Merge” option if the only difference is that the target folder contains a subset of the source folder files but those files are otherwise identical. It will also not offer to “Merge” if the only differences are in sub-folders. Setting aside how dumb this is… You can work around this by introducing a dummy file to the top level of the target folder so that it contains something the source folder does not. This causes Finder to offer to Merge and it will merge sub-folders recursively (supposedly). Remember that it will also leave the dummy file.