Automate Directory Indexes with CM dir2HTML — Tips & Examples

How to Use CM dir2HTML for Fast Directory-to-HTML Conversion

What it is

CM dir2HTML (commonly seen as dir2html / DIR2HTML) is a small utility or script that generates an HTML index of a filesystem directory (single directory or recursively). Output is a browsable HTML file (usually index.html) listing files and folders with optional columns like size, date, links, and comments.

Quick steps (Windows GUI version)

  1. Download and run the DIR2HTML executable (classic Windows freeware; last widely distributed version is 1.1.0).
  2. Select the source directory with the Browse control.
  3. Set a file mask (optional) to include only certain extensions (e.g., .mp3;.jpg).
  4. Choose depth: single directory or recursive.
  5. Pick columns to include: name (linked), size (bytes/KB/MB), date/time, blank custom column.
  6. Configure sorting (by name, size, or date) and link prefix (if hosting elsewhere).
  7. Click Create and choose output filename/location (default index.html).
  8. Open the generated HTML in your browser to verify links and layout.

Quick steps (Perl / command-line dir2html)

  1. Install Perl (if needed).
  2. Run:

    Code

    dir2html [OPTIONS] [DIRECTORY]

    Common options:

    • -o FILE — output filename (default index.html) or – for stdout
    • -r — generate indexes recursively for subdirectories
    • -c FILE — include comments from a comment file (FILENAME:COMMENTARY lines)
    • -b BASE — set base path/prefix for links
    • -t TITLE — set HTML title
  3. Example: generate recursive indexes for /srv/www/files with title:

    Code

    dir2html -r -t “File Archive” /srv/www/files

Useful tips

  • Use a comment file to add human-readable descriptions under filenames.
  • If serving over a web server, set the link prefix/base so generated links point correctly.
  • For automation, run the CLI version in a batch/cron job and commit results to your site.
  • If you need custom styling, wrap the generated HTML or post-process it (search-and-replace) to add CSS.
  • Beware: some GUI builds are old/Windows XP–era; prefer the Perl/scripted variants for portability and customization.

Alternatives

  • For modern use, consider small scripts (Python: os.walk + Jinja2) or tools like static site generators that produce richer, styled indexes.

If you want, I can:

  • generate a ready-to-run Python script that produces a styled index.html recursively, or
  • produce exact dir2html CLI commands for your OS and directory (I’ll assume /path/to/dir if you don’t specify).

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *