Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Remove bogus entries from Safari's history file Web Browsers
If you've enabled the Debug menu in Safari, you may have noticed the "Populate History" item. If you ... accidently ... click it, it fills your history with up to 1000 bogus sites. I've written a perl script that removes them.
#!/usr/bin/perl
use warnings;
use strict;
my $file="/Users/jmelloy/Library/Safari/History.plist";
$/="<array>";
open(FILE,$file) or die qq(Unable to open "$file": $!);
my $toss = <FILE>;
$/="</dict>";
my @history = <FILE>;
close(FILE);
my $outfile = "History.plist";
open(OUTFILE, ">$outfile") or die qq{Unable to open "$outfile": $!};
print OUTFILE $toss;
for(my $i = 0; $i < @history; $i++) {
if($history[$i] =~ /.*bogus.*/) {
}
else {
print OUTFILE $history[$i];
}
}
close(OUTFILE);
Copy that into a text editor, make it executable (chmod +x history.pl). All that needs to be changed is the username ("jmelloy"). It's non-destructive, it creates a new file in the same directory you ran the script from. Then, all you need to do is copy the new History.plist file to ~/Library/Safari/History.plist and you're done.

If you also want to remove "other" things from your history, all you need to change is the regular expression that matches the word "bogus".
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[4,368 views]  

Remove bogus entries from Safari's history file | 3 comments | Create New Account
Click here to return to the 'Remove bogus entries from Safari's history file' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
not natural perl
Authored by: merlyn on Feb 04, '03 12:27:15PM
for(my $i = 0; $i < @history; $i++) {
if($history[$i] =~ /.*bogus.*/) {
}
else {
print OUTFILE $history[$i];
}
}
should be replaced by
print OUTFILE grep !/bogus/, @history;
which is much more natural Perl.

[Editor's note: I cleaned up the HTML that Geeklog killed ... soon, now, that won't be a problem (Geeklog 1.3.7 is much better at it).]

[ Reply to This | # ]
Bookmarks window
Authored by: seika7 on Feb 04, '03 12:47:30PM

Wouldn't it be easier to just delete the history items from the Bookmarks window? Just click History in the left pane of the Bookmarks window to see all of your history items in the right pane. From there, you can select individual (or select all) items and hit the delete key.



[ Reply to This | # ]
Bookmarks window
Authored by: Felix on Feb 05, '03 12:45:44AM

My thoughts too!! You beat me to it.



[ Reply to This | # ]