parv
19 years ago
(Originally, i posted the below to o.general; later somebody
suggested to post it here, w/ which i agreed.)
Below is a small perl program to scrub the bookmark file. Currently,
it lowercase-s & shortens the bookmark names|titles to 36 characters,
removes icon references, creation dates, & description. Adjust as you
like.
- parv
#!/usr/local/bin/perl -i--OLD
# Make backup of the given file by adding '--OLD' to it.
use warnings; use strict;
die "No Opera bookmark files given\n" unless scalar @ARGV;
my $max_title_length = 36;
while (<>)
{
# Remove some items.
next if m/\b CREATED=/x
or m/\b ICONFILE=/x
or m/\b DESCRIPTION=/x
;
# Don't touch anything other than bookmark entry text including 'Trash'.
if ( $_ !~ m/\b NAME=/x or m/\b NAME= (?i:Trash) /x )
{ print; next; }
chomp;
# Try to minimize loss of meaningful text.
s/(?:problem|bug) \s+ (?:report|ticket)s?/pr/xi;
s/\. (?:org|com|net|gov|mil) \b//xi;
s/(?<=NAME=)(.{1,$max_title_length}).*/lc $1/e;
s/\s+$//;
print $_ , "\n";
}
__END__
suggested to post it here, w/ which i agreed.)
Below is a small perl program to scrub the bookmark file. Currently,
it lowercase-s & shortens the bookmark names|titles to 36 characters,
removes icon references, creation dates, & description. Adjust as you
like.
- parv
#!/usr/local/bin/perl -i--OLD
# Make backup of the given file by adding '--OLD' to it.
use warnings; use strict;
die "No Opera bookmark files given\n" unless scalar @ARGV;
my $max_title_length = 36;
while (<>)
{
# Remove some items.
next if m/\b CREATED=/x
or m/\b ICONFILE=/x
or m/\b DESCRIPTION=/x
;
# Don't touch anything other than bookmark entry text including 'Trash'.
if ( $_ !~ m/\b NAME=/x or m/\b NAME= (?i:Trash) /x )
{ print; next; }
chomp;
# Try to minimize loss of meaningful text.
s/(?:problem|bug) \s+ (?:report|ticket)s?/pr/xi;
s/\. (?:org|com|net|gov|mil) \b//xi;
s/(?<=NAME=)(.{1,$max_title_length}).*/lc $1/e;
s/\s+$//;
print $_ , "\n";
}
__END__
--
As nice it is to receive personal mail, too much sweetness causes
tooth decay. Unless you have burning desire to contact me, do not do
away w/ WhereElse in the address for private communication.
As nice it is to receive personal mail, too much sweetness causes
tooth decay. Unless you have burning desire to contact me, do not do
away w/ WhereElse in the address for private communication.