mmirror is a tool to merge two folder structures, having a preference when encountering duplicates. The resulting merged structure uses symbolic links at a user provided depth in the directory structures.
I wrote mmirror with my music in mind, but in reality it could be used to deduplicate any pair of folders. A depth parameter tells the script at which level symbolic links should be created, and any folder above it will actually be created. My music is organized as follows:
music/FLAC/The Lawrence Arms/ Metropole/. I run the script with
music/FLAC/ as the high quality input and I want the individual albums - not the artists - to be the symlink; thus, I run with a depth of 2.
The script requires two input directories. It's most useful when there are some subdirectories that are duplicates, but this is by no means necessary. Both the high and low outputs will contain the same dataset in name, the difference will be where the symlinks point for duplicates. By default mmirror uses absolute paths for the symlink targets. You can use relative paths with the switch
Imagine the following inputs as arrays instead of folders.
0, 1, 2, 3, 4
2, 3, 4, 5
That will yield the following output arrays, where the l and h prefix correspond to which source is used.
l0, l1, l2, l3, l4, h5
l0, l1, h2, h3, h4, 5
python mmirror.py [OPTIONS] SOURCE_HIGH SOURCE_LOW
--output_high DIRECTORYThe output directory for the high merge.
--output_low DIRECTORYThe output directory for the low merge.
--depth INTEGERDefines the depth at which symlinks will be created. 1 will link folders under source.
--followsymlinksFollow symbolic links in the source paths
--overwritesymlinksOverwrite symlinks in the output directory.
--relativeThe symbolic links should be relative paths instead of absolute paths.
--simulateSimulation mode. Don't actually do anything.
--verbose INTEGER RANGELogging verbosity,
-vvfor very verbose.
--helpShow this message and exit.
In my situation described above, I run the script from
python mmirror.py flac/ mp3/ --output_high high/ --output_low low/ --depth=2
mmirror requires click. It's a library to facilitate command line arguments. In retrospect, it probably wasn't a good idea to add a dependency, but I wanted to try it out. It's available via pip:
pip install click or
pip install -r requirements.txt if you clone the repository.