#!/usr/local/bin/perl5 # # usage: make_md5 directory >listing.md5 # # finds all the files under the given directory (avoiding any obvious # thumbnail directories), and gives their MD5 signatures to stdout. # progress is shown to stderr. # # suggestion: when making a listing, start from a root directory # that has a unique name, to make later grepping easier. i.e: # mv ~/pr0n pr0n2002may # make_md5 pr0n2002may >~/Misc/Disc/pr0n2002may.md5 # (burn CDR from pr0n2002may, remove, label the CDR accordingly) # then later.. # grep cat ~/Misc/Disc/everything.md5|grep maid # might print: # "245t98uerguih245mumble pr0n2002may/Anime/killer_catgirl_maid09.jpg" # # -- # Copyright 1995-2002 Chris Baird . # GNU Copyleft V2 copying conditions if you're incapable of writing your # own from scratch, blah, blah.. $cksum="/usr/bin/md5"; # BSD MD5, maybe? $N=10; $|=1; sub fixname { local($f); s/\n//g; s/\ /\\ /g; s/\'/\\'/g; s/\"/\\"/g; s/\&/\\&/g; s/\`/\\`/g; s/\!/\\!/g; s/\(/\\(/g; s/\)/\\)/g; $f = $_; } $rootsearch = shift @ARGV; open(FIND, "find $rootsearch -type f -print|"); while () { $filename = &fixname($_); next if /xvpics/; next if /\.db\//; print STDERR ++$count, "\t $filename \r"; push(@allfiles, $filename); # XXX scary for large filesystems } print STDERR "\n\n"; # splice the first N (or whatever's left) filenames # and feed to $cksum while ($#allfiles >= 0) { if ($#allfiles < $N) { $N = $#allfiles }; $a = join(" ", splice (@allfiles, 0, $N +1)); print STDERR $a, "\n\n"; open(CKSUM, "$cksum $a |"); while () { chop; # NB: dependent on output format of BSD MD5; GNU might be different ($b, $fcksum) = ($_ =~ /^MD5 \((\S+)\) = (\S+)/); $fname = $b; print "$fcksum\t$fname\n"; } }