ubuntu:file:delete_duplicate_files
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ubuntu:file:delete_duplicate_files [2020/02/01 14:38] – peter | ubuntu:file:delete_duplicate_files [2022/06/13 10:22] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Ubuntu - File - Delete duplicate files ====== | ||
- | |||
- | <code bash> | ||
- | find . -regex '.* ([0-9]).*' | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | <code bash> | ||
- | find " | ||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | <code bash> | ||
- | |||
- | </ | ||
- | |||
- | ---- | ||
- | |||
- | ===== Using rdfind ===== | ||
- | |||
- | **Rdfind** stands for redundant data find; and is a free and open source utility to find duplicate files across and/or within directories and sub-directories. | ||
- | |||
- | It compares files based on their content, not on their file names. | ||
- | |||
- | Rdfind uses ranking algorithm to classify original and duplicate files. | ||
- | |||
- | Once it found the duplicates, it will report them to you. You can decide to either delete them or replace them with hard links or symbolic (soft) links. | ||
- | |||
- | <code bash> | ||
- | sudo apt install rdfind | ||
- | |||
- | rdfind ~/Downloads | ||
- | |||
- | rdfind -deleteduplicates true ~/. | ||
- | </ | ||
- | |||
- | <WRAP info> | ||
- | NOTE: rdfind saves the results in a file named results.txt in the current working directory. | ||
- | |||
- | You can view the name of the possible duplicate files in results.txt file. | ||
- | |||
- | By reviewing the results.txt file, you can easily find the duplicates. | ||
- | </ | ||
- | |||
- | You can use the **-dryrun** option to find all duplicates in a given directory without changing anything and output the summary in your Terminal: | ||
- | |||
- | <code bash> | ||
- | rdfind -dryrun true ~/Downloads | ||
- | </ | ||
- | |||
- | Once you found the duplicates, you can replace them with either hardlinks or symlinks. | ||
- | |||
- | To replace all duplicates with hardlinks, run: | ||
- | |||
- | <code bash> | ||
- | rdfind -makehardlinks true ~/Downloads | ||
- | </ | ||
- | |||
- | To replace all duplicates with symlinks/ | ||
- | |||
- | <code bash> | ||
- | rdfind -makesymlinks true ~/Downloads | ||
- | </ | ||
- | |||
- | You may have some empty files in a directory and want to ignore them. If so, use -ignoreempty option like below. | ||
- | |||
- | <code bash> | ||
- | rdfind -ignoreempty true ~/Downloads | ||
- | </ | ||
- | |||
- | If you don’t want the old files anymore, just delete duplicate files instead of replacing them with hard or soft links. | ||
- | |||
- | To delete all duplicates, simply run: | ||
- | |||
- | <code bash> | ||
- | rdfind -deleteduplicates true ~/Downloads | ||
- | </ | ||
- | |||
- | If you do not want to ignore empty files and delete them along with all duplicates, run: | ||
- | |||
- | <code bash> | ||
- | rdfind -deleteduplicates true -ignoreempty false ~/Downloads | ||
- | </ | ||
- | |||
- | For more details, refer the help section: | ||
- | |||
- | <code bash> | ||
- | rdfind --help | ||
- | </ | ||
- | |||
- | And, the manual pages: | ||
- | |||
- | <code bash> | ||
- | man rdfind | ||
- | </ | ||
ubuntu/file/delete_duplicate_files.1580567889.txt.gz · Last modified: 2020/07/15 09:30 (external edit)