User Tools

Site Tools


ubuntu:file:delete_duplicate_files

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
ubuntu:file:delete_duplicate_files [2020/02/01 14:38] peterubuntu: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]).*' -delete 
-</code> 
- 
----- 
- 
-<code bash> 
-find "$@" -type f -print0 | xargs -0 -n1 md5sum | sort --key=1,32 | uniq -w 32 -d --all-repeated=separate | sed -r 's/^[0-9a-f]*( )*//;s/([^a-zA-Z0-9./_-])/\\\1/g;s/(.+)/ls \1/' 
-</code> 
- 
----- 
- 
-<code bash> 
- 
-</code> 
- 
----- 
- 
-===== 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.  If you have two or more equal files, Rdfind is smart enough to find which is original file, and consider the rest of the files as duplicates. 
- 
-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 ~/. 
-</code> 
- 
-<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 remove the duplicates manually if you want to. 
-</WRAP> 
- 
-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 
-</code> 
- 
-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 
-</code> 
- 
-To replace all duplicates with symlinks/soft links, run: 
- 
-<code bash> 
-rdfind -makesymlinks true ~/Downloads 
-</code> 
- 
-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 
-</code> 
- 
-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 
-</code> 
- 
-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 
-</code> 
- 
-For more details, refer the help section: 
- 
-<code bash> 
-rdfind --help 
-</code> 
- 
-And, the manual pages: 
- 
-<code bash> 
-man rdfind 
-</code> 
  
ubuntu/file/delete_duplicate_files.1580567889.txt.gz · Last modified: 2020/07/15 09:30 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki