find all the same named directories on a hard disk
Hello,
my harddisk has a great amount of the same named directories all over the place. most of the time they hold the same data. i don't wanna use a compare tool to go through each file... at least not at this time. i just would like to know where the same named directories are, and merge them together... i haven't found a tool that can do this out of the box. i guess this has to be done by scripting. and i'm not a scripting wizard. i think it might be interesting having a script that compares one directory against the rest of the harddisk ? can anybody point me to a solution ? for example which command to use: i thought of the find command ? i think this might help me... but then i would need to check how much % is the same, and if it holds a large % of the same files, i would like to merge it. find /disk -type d -name "Documents" thank you very much kind regards |
Yup. find will do that for you with minimal (if any) scripting. See man find
|
You might look at fslint or fdupes.
Or if you work with find you can use -exec to make a checksum for each file and pipe that into sort and then into uniq. With the right option(s) uniq will show duplicates. |
Maybe run tree & pipe it to a file to peruse later using any text program, (cat/less/more/vi/nano/etc).
(Then you could just copy them all into one directory.) Code:
tree /home > textfile |
Quote:
And cat is unecessary (--> grep 'pdf' textfile) ;) @fillemon: IMO, the simplest approach is Turbocapitalist's. I would suggest something like: Code:
find /disk -type d -iname '*documents*' -exec basename {} \; | sort | uniq -d Code:
find /disk -type d -name 'exact_folder_name' Code:
find /disk -type d -name "Documents" |
Quote:
Code:
find /dir01/ /dir02/ -type f -exec md5sum {} \; \ |
Quote:
Of course that may only a subset depending on prune options, but should be pretty complete for most use cases. |
Quote:
@fillemon: can you be more specific please? Do you want to search folders that have the same names, or duplicate files? |
you'd might have a two part'er, first find dup directories, then using that search for dup file in the found dup directories. Going back to @Turbocapitalist suggestion of using fslint or fdupes. Perhaps along with find.
or something "crazy" like this, NOT Completely working code, the theory is there, but needs work. (I'm not feeling like setting up a dup directories, and dup files, to test this code until I get it to work properly) Code:
#!/bin/bash |
@ l0f4r0
Just trying to keep things simple as it is the OPs first post. :) |
All times are GMT -5. The time now is 07:42 PM. |