0

I have 2 folders that I need to merge.

Inside each folder are subfolders. In about 50% of the cases these subfolders exist in both parent folders.

E.g.

 FOLDER 1 | FOLDER 2
  --------------------- 
    SUB 1 | SUB 1 

    SUB 2 | SUB 2 

    SUB 3 | SUB 3 

Although the subfolders have the same names, they do not include the same data and I would like these to be merged. It's not a case of one overwriting the other they actually need to be merged as each contains unique data.

Is that possible in Mac OS X 10.10? I also have access to the same folder via Dropbox on other machines running Mac OS X 10.11 and macOS 10.13.

  • 1
    As you mentioned that despite having the same names for files and folder, the data contained may not be the same. My suggestion would b to perform the merge manually. To make things simple, you can initialise a Git repository in any one of them, stage, and commit all the files. After that, copy over the contents of other directory, replacing all files and folders. Now you can view the modified data in the repository and easily perform the merge. – Nimesh Neema Mar 27 '18 at 17:29
2

From macOS Sierra documentation.

Merge two folders with the same name:

If you have two folders with identical names at two different locations, you can merge them into a single folder.

Press and hold the Option key, then drag one folder to the location that contains a folder with the same name. In the dialog that appears, click Merge.

The Merge option appears only if one of the folders contains items that are not in the other folder. If the folders contain different versions of identically named files, the only options are Stop or Replace.

https://support.apple.com/kb/PH25633

1

Open a Terminal, and use ditto:

ditto [source] [destination]

For example:

$ cd ~
$ mkdir A/
$ mkdir A/1
$ mkdir A/2
$ mkdir A/3
$ touch A/1/1.txt
$ touch A/2/2.txt
$ mkdir B
$ mkdir B/1
$ mkdir B/3
$ touch B/1/x.txt
$ touch B/3/z.txt
$ ditto A B
$ open .
  • 1
    El Capitan does not have merge, but it does have ditto. – lhf Nov 7 '18 at 9:41
  • I advise to use the -V option to see the progress of this command. This is a nice way to check it is doing exactly what is expected. – daniel Azuelos Jan 14 at 11:12
  • 1
    the dummy folder structure can be created in one line: mkdir -p A/{1..3} B/{1,3} Or: mkdir -p {A,B}/{1..3};rm -r B/2 – Yoric Jan 14 at 11:19
  • Notice that you get the same result with rsync -avh A/* B/ – Yoric Jan 14 at 11:42
-1

This article at the link below will help you set up an Automator Action to merge folders... or if you're comfortable in Terminal, you could just use Rsynch - the relevant commands are in this article too.

https://www.bananica.com/Geek-Stuff/Synchronize-two-folders-on-a-Mac-with-Automator-and-Rsync/

You must log in to answer this question.

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