CM dir2HTML Tutorial: Create Custom HTML File Trees from Folders
What it is
CM dir2HTML is a directory-to-HTML utility (variants exist as Dir2HTML, dir2html, DIR2HTML) that converts a filesystem folder and its subfolders into browsable static HTML index pages — useful for static sites, project archives, intranet file lists, or CD/DVD catalogs.
Key features
- Recursive traversal producing nested lists or per-directory index.html files
- Custom templates and header/footer includes for styling and branding
- Filtering (include/exclude patterns, show/hide hidden files)
- Sorting (by name, size, date) and display options (size, mtime, permissions)
- Link generation with relative paths suitable for static hosting
- Optionally supports MD5 checksums, comment/description files, and archive flags (depends on implementation)
Typical workflow
- Choose a root folder to publish (e.g., ./public).
- Configure options (recursive, template, sort order, exclude patterns) via CLI flags or an INI/config file.
- Run dir2HTML to generate index.html (single file or one per directory).
- Edit template/CSS to style the output.
- Deploy generated HTML to your static host or copy to file shares.
Common command options (examples)
- –recursive or -r — traverse subdirectories
- –template PATH — use custom HTML template
- –output FILE or -o — set output filename (default index.html)
- –exclude PATTERN — skip matching files
- –sort [name|size|date] — ordering
- –show-size / –show-mtime — include extra columns
Customization tips
- Use placeholders in templates for filename, relative URL, size, and mtime.
- Generate one index per directory if you need links that work on GitHub Pages or simple web servers.
- Add CSS to improve readability (wrap long names, collapse deep trees).
- Wrap the tool in a small script to pre-format names or compute human-readable sizes.
When to use it
- Publishing a lightweight file index without a CMS
- Sharing project artifacts, builds, or downloads on static hosting
- Creating snapshots of directory structures for documentation or archives
Leave a Reply