#! perl -w # MSIEHTML.PL -- Traverse the Internet Explorer Favorites list # and generate an HTML bookmark file # # Usage: msiehtml ["Title"] # Title is optional, otherwise defaults to "Title: " # # D. Moisan 2/9/96 # Last modified 3/9/96 # ($favlist, $htmlout, $title) = @ARGV; unless ($favlist || $htmlout) { #At least favlist and htmlout must be specified die ("Usage: msiehtml \[\"Title\"\]"); } open(HTML, ">".$htmlout); unless ($title) { #Default title if not specified $title="Directory $favlist"; } $today = localtime; $URLcount = 0; # Produce HTML title and heading tags print HTML ("\n\n$title"); print HTML ("\n\n\n"); print HTML ("

$title

\n
    \n"); print HTML ("$today\n"); favscan ($favlist, ''); print HTML ("\n
\n\n\n"); print STDOUT ("\nURL's Converted: $URLcount \n"); close(HTML); exit; sub ht_head { # Write HTML subheading for each favorites directory my($head)=$_[0]; print HTML ("\n

$head

\n
    \n"); return; } sub favscan { my($dirname) = $_[0]; local ($file)= $_[1]; my(@contents); #Handle case of $file being null in the beginning #$file is used just for the headings if ($file) {$dirname = $dirname."\\".$file;} # If it's a file, open the shortcut if (-f $dirname) { openurl ($dirname,$file); } # If it's a directory, print its heading and keep recursing down elsif (-d $dirname) { ht_head($file); opendir(X, $dirname); @contents = readdir(X); closedir(X); foreach $file (@contents) { # Skip '.' and '..' directories next if ($file eq "." || $file eq ".."); favscan($dirname, $file); } ht_break(); #Paragraph break } else { print STDERR ("$dirname Not Found \n"); } return; } sub ht_break { print HTML ("
    "); return; } sub openurl { # Opens a URL file and extracts the URL my($urlname)=$_[0]; local($file)=$_[1]; my(@url,@urlname); # print STDERR "URL File:$file \n"; #Debugging open(URL, $urlname); #if .URL extension and shortcut header present then read URL if ( =~ m/[InternetShortcut]/ and $urlname =~ m/.url/i) { @url = split(/=/,); #Get exp on right side of "URL=" #Remove .URL extension from name... @urlname = split(/.url/i,$file); $file=$urlname[0]; unless ($url[1]) { print STDERR ("$urlname has no URL associated with it! \n"); } else { #...and extra quotes and the CR at the end $url[1] =~ s/\"//g; chomp($url[1]); print HTML ("
  • $file\n"); $URLcount++; } } else { print STDERR ("$file not an Internet Shortcut \n"); } close(URL); return; }