New on LowEndTalk? Please Register and read our Community Rules.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
Delete duplicate directories?
Is there a way via some bash script or just cmd to find duplicate directories and delete?
i have main folders:
TEST1
TEST2
In folder TEST1 is some amount of same folders as in folder TEST2
can be this done? i tried fdupe but it only search for dupe files not whle dirs
thx!
Comments
that use case is some kind of odd and probably hard to achieve.
how should a script determine what you want to have removed from which of both folders? what esp. should happen with folders that include more or slightly different files, shall they be delete to or only the files or should they be left untouched?
easiest way may be to remove files with fdupes like you intended and afterwards remove only empty dirs (which probably are the ones left over) via
if you only want to spare on diskspace I recommend looking into hardlinking duplicate files, but please do try to understand the concept of hardlinking before using it ;-)
I can recommend jdupes over fdupes for handling duplicate files anyways: https://github.com/jbruchon/jdupes
or you use a filesystem with automatic file de-duplication support
Depends upon the programming language used
You could alwats run php from cli and pass two dirs with their paths and simply map their directory structure in a single multi dimensional array and if both match then remove one....
But you need to do lots of coding yourself :-)
Like Falzo says, it depends on what you actually want the end result to be. Any time I'm looking to do things with mostly identical file hierarchies, I consider if
rsync
can get it done. Perhaps your problem can be solved by making both directories duplicates of each other, and then just deleting one of them.