dirtree2html (2002 Dec 1)

This python script creates fancy output showing a directory strucure, with links to the files if you want.

Example:
./dirtree2html02.py "." "img/" 1 >middle.html
That's the output:
(leave out the third parameter to have output without links)
 .  
     base.html399HTML
     cdrom.html15.974HTML
     dirtree2html01.py6.182Python source
     dirtree2html02.py8.306Python source
     dirtree2html02.py~6.602Old python source
     dirtree2html_02.tgz9.254TAR GZ archive
     img  
         .xvpics  
             dot.png213Graphics
             htmlfile.png389Graphics
         dot.png134Graphics
         folder.png258Graphics
         gfxfile.png715Graphics
         htmlfile.png574Graphics
         somefile.png231Graphics
         textfile.png273Graphics
     index.html8.874HTML
     middle.html4.096HTML
     t115.974
     tail.html3.311HTML

It is possible to configure the colors and icons in two lists in the source of the python script:
                   # ccode  colo[u]r   name       html-open   -close
color_codes_info = [ ( 0, '#000000', 'default',       '',    ''     ),
                     ( 1, '#000000', 'directory',     '', '' ),
                     ( 2, '#000000', 'unknown files', '',    ''     ),
                     ( 3, '#00DD00', 'executables',   '', '' ),
                     ( 4, '#009999', 'text files',    '',    ''     ),
                   ]

                   #  ext   ccode  description           icon
extensions_info = [ ("py",   0, "Python source"    , "textfile.png"),
                    ("py~",  0, "Old python source", "textfile.png"),
                    ("pyc",  0, "Python byte code" , "textfile.png"),
                    ("pl",   0, "Perl source"      , "textfile.png"),
                    ("c",    0, "C source"         , "textfile.png"),
                    ("cpp",  0, "C++ source"       , "textfile.png"),
                    ("cc",   0, "C++ source"       , "textfile.png"),
                    ("java", 0, "Java source"      , "textfile.png"),
                    ("class",0, "A class file"     , "textfile.png"),
                    ("ply",  0, "plynets data"     , "somefile.png"),
                    ("txt",  4, "Text"             , "textfile.png"),
                    ("gz",   0, "GZ archive"       , "somefile.png"),
                    ("tar",  0, "TAR archive"   , "somefile.png"),
                    ("tgz",  0, "TAR GZ archive"   , "somefile.png"),
                    ("png",  0, "Graphics / PNG"   , "gfxfile.png"),
                    ("gif",  0, "Graphics / GIF"   , "gfxfile.png"),
                    ("jpg",  0, "Graphics / JPG"   , "gfxfile.png"),
                    ("jpeg", 0, "Graphics / JPG"   , "gfxfile.png"),
                    ("tif",  0, "Graphics / TIF"   , "gfxfile.png"),
                    ("tiff", 0, "Graphics / TIFF"  , "gfxfile.png"),
                    ("tga",  0, "Graphics / TGA"   , "gfxfile.png"),
                    ("ico",  0, "Graphics / Icon"  , "gfxfile.png"),
                    ("html", 0, "HTML"             , "htmlfile.png"),
                    ("htm",  0, "HTML"             , "htmlfile.png"),
                    ("iso",  0, "ISO image"        , "somefile.png"),
                    ("img",  0, "Floppy image"     , "somefile.png"),
                    ("pdf",  0, "Portable Document format"  , "somefile.png"),
                    ("bat",  0, "DOS batch file"   , "textfile.png"),
                    ("exe",  0, "DOS executable"   , "textfile.png"),
                    ("com",  0, "DOS executable"   , "textfile.png"),
                    ("dll",  0, "Windoze library"  , "textfile.png"),
                    ("ogg",  0, "Music / Ogg"      , "textfile.png"),
                    ("mp3",  0, "Music / MP3"      , "textfile.png"),
                    ("bak",  0, "Old version"      , "somefile.png"),
                  ]
default_extension_info = ("", 0, ""   , "somefile.png" )

If you want to make your own files take "somefile.png" as template.

Future plans: