Updated 2013-09-18 23:35:45 by RLE

GPS: March 1, 2004: I had many .URL files from Windows that stored URLs that I wanted to extract and make HTML from. So, I came up with this in ~5 minutes (Tcl is fun and easy).

OLL
 #Get a pattern of URL=$foo\n where $foo is the URL we want.
 proc fetch.url s {
  set i [string first URL= $s]
  if {$i < 0} {return ""}
  string range $s [expr {$i + 4}] [string first \n $s $i]
 }

 proc main {argc argv} {
  if {$argc < 2} {
   return -code error "outfile infiles ..."
  }
  set out_fd [open [lindex $argv 0] w]
 
  set s "<html>
   <head>
   <title>[lindex $argv 0]
   </title>
   </head>
   <body>
  "

  foreach f [lrange $argv 1 end] {
   set fd [open $f r]
   set url [fetch.url [read $fd]]
   close $fd
   if {"" == $url} continue  
   append s "<a href=\"$url\">$url</a><br>\n"
  }
  append s "</body>"
  puts $out_fd $s
 }
 main $::argc $::argv

Now here is the url_to_html.tcl.plan file:
 For output:
 open [lindex $argv 0] w

 open all files passed in [lrange $argv 1 end] and search for URL= via string first or regexp.