[Python] MS Explorer Favorites to HTML

Looks through the MS Explorer Favorites folders producing an HTML page with the corresponding URLs as links to them, conveniently formatted

#!/usr/bin/env python
# Looks through the given Favorites folder and
# prints out an HTML page with their links.
# (copyleft) Jose M Beas, 2003

import string, sys, os, ConfigParser

def processURL(filename):
    name = os.path.split(filename)[1]
    name = os.path.splitext(name)[0]
    config = ConfigParser.ConfigParser()
        url = config.get("InternetShortcut","URL")
        print "<A HREF=\"%s\">%s<A/><BR/>" % (url,name)
    except ConfigParser.NoSectionError:
        print >>sys.stderr, "Could not found URL in %s" % (filename)
def processFile(filename):
    # Checks if it is a URL and process it (if so)
    if os.path.splitext(filename)[1] == ".url" :
def processDir(dirname,level):
        filenames = os.listdir(dirname)
    except OSError, err:
        print >>sys.stderr, err
    section = os.path.split(dirname)[1]
    files = []
    folders = []
    for filename in filenames:
        fullname = os.path.join(dirname, filename)
        if os.path.isdir(fullname):
    print "<H%d>%s</H%d>" % (level,section,level)
    for i in files:
    for i in folders:
        print "<UL>"
        print "</UL>"
def main(argv):
    import getopt   
        args, dirname = getopt.getopt(argv[1], "h", ["help"])
    except getopt.error:
        args = "dummy"
    if args:
        print "Usage: %s <directory>" % (argv[0],)

    if not dirname:
        dirname = ["."]
    print "<HTML>"
    print "</HTML>"

if __name__ == "__main__":

가장 많이 본 글