Does Mozilla seem to be really slow with bookmarks?  Has your 
bookmarks file mysteriously become huge and bloated?  The following 
Perl script might help; I used it to shrink my bookmarks file from 
17,000 lines to 700 lines.  Backup your bookmarks file before trying 
this; command line usage is "script.pl infile outfile".

======================cut here==============================
#!/usr/bin/perl

use strict;

my $IN_FILENAME  = $ARGV[0];
my $OUT_FILENAME = $ARGV[1];

my $USAGE = "USAGE: book-shrink.pl infile outfile\n";

unless (@ARGV == 2) {
  die "$USAGE";
}

if ($IN_FILENAME eq $OUT_FILENAME) {
  print STDERR "ERROR: infile can't be the same as outfile\n";
  die "$USAGE";
}

unless(open(INFILE, "$IN_FILENAME")) {
  die "Couldn't open '$IN_FILENAME' for reading: $!\n";
}

unless(open(OUTFILE, ">$OUT_FILENAME")) {
  die "Couldn't open '$OUT_FILENAME' fore writing: $!\n";
}

my %bookmarks    = ();
my $infileLines  = 0;
my $outfileLines = 0;

while(<INFILE>) {
  $infileLines++;
  if (/HREF/) {
    next if ($bookmarks{$_});
    $bookmarks{$_} = 1;
  }

  print OUTFILE $_;

  $outfileLines++;
}

close(INFILE);
close(OUTFILE);

print "Lines in '$IN_FILENAME':  $infileLines\n";
print "Lines in '$OUT_FILENAME': $outfileLines\n";
print "\n";

exit(0);

=======================cut here================================

-- 
Matthew Cline        | Suppose you were an idiot.  And suppose that
[EMAIL PROTECTED] | you were a member of Congress.  But I repeat
                     | myself.  -- Mark Twain

Reply via email to