IN-Decent

Re-decentralizing internet with free software

Generate Directory File Listing as a Static index.html

Posted at — Aug 26, 2021

When a web server does not allow directory listing of files inside, for whatever reasons. tree command can be used to generate a simple index.html file, that lists the contents of your directory, which can then be used to browse the contents of your directory from web server.

tree -H '.' -L 1 -P "*.html" --noreport --prune -T "Doc title" > index.html

Above command will generate a simple index.html file which contains the link to all .html files in your current directory.

tree command also supports JSON and XML outputs using -J and -X options respectively.

References:

  1. stackoverflow.com
  2. man tree