MacOS – How to combine two or more folders into one AFP or SMB network share in OS X 10.11

afpfile-sharingmacosNetworksmb

I have two media directories that each have a similar top-level folder structure. I'd like to share them over my network, using either AFP or SMB, in such a way that I can access both of them using one share, with the contents of both directories merged together.

So if folderA has the following contents:

|__ Stuff
| |__ My Stuff
|   |__ fileA.txt
|   |__ fileB.txt
|
|__Things
  |__ video1.avi
  |__ video2.mkv

…and folderB has the following contents:

|__ Stuff
| |__ My Stuff
| | |__ fileC.txt
| |
| |__ Your stuff
|   |__ fileD.txt
|
|__Things
  |__ video3.ogm
  |__ video4.rm

…then the network share would appear as the following:

|__ Stuff
| |__ My Stuff
| | |__ fileA.txt
| | |__ fileB.txt
| | |__ fileC.txt
| |
| |__ Your stuff
|   |__ fileD.txt
|
|__Things
  |__ video1.avi
  |__ video2.mkv
  |__ video3.ogm
  |__ video4.rm

If new files are copied into the share, preferably I'd be able to configure which of the two top level folders they are placed into.

I had originally accomplished this by compiling the mhddfs filesystem for OS X, using it to mount a virtual filesystem that was a combination of my two folders and then sharing that over the network. But after a year or so of use I've found that mhddfs is unstable, at least in OS X. Numerous filesystem errors accumulated across my drives that eventually led to hard system crashes, the drive would often unceremoniously unmount for no apparent reason, and various other unsavory things would happen like copying an application bundle to the network drive and having its individual files be split up between the two shares. Hence why I'm interested if there's a file server solution to this, rather than something more prone to serious errors like a file system solution.

Best Answer

A new folder could be created 'Folder' (with Folder A/Folder B hidden by adding '.' before the folder names). In that new folder 'Folder', links to each of the files could be created. When folders are found in '.Folder A' or '.Folder B' a new folder and path is created in Folder.

A script could go through and first create the folders in 'Folder'. The script would then go through and create links to each of the files.

This is hokey as heck, but may work (for Macs and linux machines). Each of these steps is a single find command (or a find command calling another script).

That's a non-eligant but simple solution. If you'd like me to write/test the two commands I will.