Recently I have bought an USB hard-disk which is 2TB for $90 from US. And I have copied some English movies around 500GB from one of my friends Hard disk. Then when I am checking the content I found that some of the movies are repeated and that to with different names, in different folders etc. This made finding them difficult. So how to find all those files and deleted them if not required.  There is one command in Linux called fdupes(File DUPlicatES) which is not installed by default. Lets see how we can use it.

In Redhat/Fedora/CentOS

#yum install fdupes 

In Debain/Ubuntu

#apt-get install fdupes

Once installed you can use right away to find duplicates..

To find duplicates in a folder

#fdupes /path/to/folder

This will find all the duplicate files in that folder. What about if you want to find in sub folders too?

Use -r option to recursive search..

#fdupes -r /path/to/folder

but this will not show what is the size of that duped files? Then there is any option to find sizes too? Yes you can use -S to find sizes too..

#fdupes -S -r /path/to/folder

What about deleting them with a conformation so that you no need to go into every folder and delete them.

#fdupes -d -r /path/to/folder

Sample output

#fdupes -d -S -r /media/Movies/

[1] /media/Movies/ENGLISH MOVIES/The Pursuit of Happyness.avi
[2] /media/Movies/ENGLISH MOVIES/The.pursuit.of.happyness.(2006)/The Pursuit of Happyness.avi

Set 1 of 13, preserve files [1 - 2, all] (735221760 bytes each): 1

[+] /media/Movies/ENGLISH MOVIES/The Pursuit of Happyness.avi
[-] /media/Movies/ENGLISH MOVIES/The.pursuit.of.happyness.(2006)/The Pursuit of Happyness.avi

if you see i just deleted first files(+) and which is not deleted is shown in above output. Enjoy with the command and give us feedback at http://forums.linuxnix.com

The following two tabs change content below.
Mr Surendra Anne is from Vijayawada, Andhra Pradesh, India. He is a Linux/Open source supporter who believes in Hard work, A down to earth person, Likes to share knowledge with others, Loves dogs, Likes photography. He works as Devops Engineer with Taggle systems, an IOT automatic water metering company, Sydney . You can contact him at surendra (@) linuxnix dot com.