SPUG: mkfavhtm.pl -- Converting IE favorites to HTM (unix/mozilla users just ignore me)

Aaron West tallpeak at hotmail.com
Mon Jul 10 11:11:16 PDT 2006


Hardly spug-relevant, and half+ of you guys probably are mozilla users, but
here goes...
 
Is your Internet Explorer Favorites list too full of junk? You *could*
organize it, but I was too lazy for that. (I always liked Netscape bookmarks
better, yet lately I'm an IE user.) 

I'm sure someone has a better solution, but here's mine; a script that reads
all *.url files in the favorites folder and outputs HTML. When you are done
you can del *.url (if you like the resulting page), or move or archive them
(recommended). ZIP has some filename restrictions; I found WinRAR works.

Alright, I admit a hashtable isn't necessary. I could use a list, but a
hashtable seemed easy, as long as you can remember the key element (comma)
separator in hashtables is "\x1c".

The sort below is by modification date. Change to your liking, eg:

1,$ s/$mtime, $url, $filename/$filename, $mtime, $url/

# mkfavhtm.pl - 7/09/2006 Aaron W. West tallpeak at hotmail.com
# Usage: run inside the favorites directory, eg:
# CD "%HOME%\Favorites"
# perl mkfavhtm.pl > favorites.htm
use strict;
use HTTP::Date;
print "<HTML><HEAD><TITLE>IE Favorites</TITLE></HEAD>\n";
print "<BODY><H1>IE Favorites</H1>\n<UL>";
my %url;
while ( defined( my $filename = <*> ) ) {
    if ($filename =~ /\.url$/i) 
    {
	my (
	    $dev,  $ino,   $mode,  $nlink, $uid,     $gid, $rdev,
	    $size, $atime, $mtime, $ctime, $blksize, $blocks
	) = stat($filename);
	open FH, "<$filename" || die "Can't open file $filename";
	my $url = undef;
	while ( defined( my $line = <FH> ) ) {
	    if ( $line =~ /^URL=([^\r\n]*)/ ) {
		$url = $1;
	    }
	}
	close FH;
	$filename =~ s/\.url$//;
	$url{ $mtime, $url, $filename }++ 
	    if defined $url;
    }
}

for ( sort keys %url ) {
    my ( $mtime, $url, $filename ) = split( "\x1c", $_ );
    printf qq{<LI><a href="%s">%s</a> - %s\n}, 
	$url, $filename, HTTP::Date::time2str($mtime);
}
print "</UL>\n</BODY>\n</HTML>\n";
__END__

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.10/384 - Release Date: 7/10/2006
 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.10/384 - Release Date: 7/10/2006
 


More information about the spug-list mailing list