One of the most inconvenient problems occuring on a typical workstation is the problem od duplicate files.
From time to time I copy something somewhere temporarily, or download the same thing many times to different locations.
Such duplicate files can have different names and lie in different directories, but they contain the same data and eat up disk space unnecessarily.
Unfortunately, I didn't manage to find a ready-made utility to effectively detect and reduce such files. And the task is very simple algorithmically.
Actually one needs toproceed along the following scheme:
After conceiving this algorithm (although I don't suppose to be the first one to come up with it) I've implemented it in the form of two Perl scripts:
The scripts are available for download below.
(Update 2008-06: it seems that there's already a program that does this plus more: http://fslint.googlecode.com/svn/trunk/doc/FAQ [1]. The algorithm they use is the same, but it additionally checks whether the duplicate files arent hardlinks of each other and uses SHA1 checksum in addition to MD5. The program has a nice GUI. In short, I recommend checking it out too!)
Jednym z bardziej uciążliwych problemów zdarzających się na domowej stacji roboczej jest dla mnie problem zduplikowanych plików.
Czasami coś się dokądś tymczasowo skopiuje, czasem dwa razy ściągnie to samo z sieci.
Takie duplikatowe pliki mogą mieć zupełnie różne nazwy i leżeć mogą w różnych katalogach, lecz zawierają to samo i zżerają niepotrzebnie miejsce.
Niestety nie znalazłem gotowego narzędzia, pozwalającego skutecznie takie pliki wykryć i zredkować. A zadanie jest bardzo proste algorytmicznie.
Otóż wystarczy postąpić według następującego schematu:
Po wymyśleniu algorytmu (chociaż nie sądzę, abym był pierwszy, który wpadł na ten pomysł) wcieliłem go w życie w postaci dwóch skryptów w języku Perl:
Skrypty do ściągnięcia poniżej:
| Załącznik | Rozmiar |
|---|---|
| dupes_symlink_single_dir.pl.txt [2] | 2.87 KB |
| dupes_symlink_two_dirs.pl.txt [3] | 3.86 KB |
Links:
[1] http://fslint.googlecode.com/svn/trunk/doc/FAQ
[2] http://olo.org.pl/dr/files/dupes_symlink_single_dir.pl.txt
[3] http://olo.org.pl/dr/files/dupes_symlink_two_dirs.pl_.txt