find-duplicate-files
A file walk util that allows you to find duplicates in given sub directories (tree). The file walk is recursive. Duplicate means that the content of two or more files is equals (checked via md5 check sum).
The directory and all sub directories will be scanned. A given file pattern will reduce the list of scanned files.
For big (static) files it can be usefull to use a md5 mapping file. This mapping file will be created a the first run. Following runs can take the md5 from the mapping file, if an entry exists. If a new file found, the md5 will be calculated and added to the mapping file.
The md5 calculation can take a long time via network and big data sets (5 hours for 1 TB data and GBit network connection).
Usage
var fdf = ;
var fdf = ;
Options
Key | Possible values | Comment |
---|---|---|
silent | true / false (default) | true will skip logging (except errors) |
checkPattern | A regular expression for file names (/.jpg$/g). Can be null. | null means: all files |
md5File | Specifies a text file for md5 / file name mapping. Can be null. Default: 'md5.json' | null means: 'md5.json' in the first given directory ('path'). You can set a different name (relative or absolute path) |
md5SkipSaving | true / false (default) | true means: no md5 file shall be saved. |
md5SkipLoading | true / false (default) | true means: no md5 file shall be used (if exists). |
Examples
var findDuplicateFiles = ; // Basic usage (a default callback handler will log the results):; // Sample config for ebooks (big static data set):
Sample callback handler
Debug only:
{ if err return console; console;});
Writing a cleanup shell script:
{ if err return console; var cmds = ; groups; // forEach // Write shell script to file (but don't execute it): var stream = fs; stream; // stream });
Auto delete callback handler (madness mode):
{ if err return console; groups; // forEach});