#!/usr/local/bin/perl
   use GDBM_File;
   use Fcntl;
  system("find . -type f -print >fnames.txt");
    umask(0);
    $x=tie(%HIST, 'GDBM_File', 'filenames.db', O_CREAT|O_RDWR, 0644)
      || die "cant open tiefile $!";
   if (defined($ARGV[1])) { open($IN,"<".$ARGV[1]); } else { $IN = STDIN; }
   $n = 0;
   $dirn = 0;
   
   while (<$IN>) {
       s/^\.\///;
       if ( /\/thumbs\// ) { next; }
       $d = $_ ;
       $d =~ s/\/[^\/]$/
       $d =~ s/.*\///;
       if ( ! defined($dirs{"$d"}) ) { 
                $HIST{"d$dirn"} = $d;
                $dirn++;
       }
       s/[\r\n]+$//;
       $HIST{"$dirn.$n"}=$_;
       $n++;
   }
   untie(%HIST);
   system('mv filenames.db data');
