是否需要创建一个HTML 文件(HTML file)来列出特定 Windows 目录中的所有文件和文件夹(lists all the files and folders in a particular Windows directory)?可能不是您需要经常做的事情,但它确实偶尔会派上用场。
例如,如果您想在Window 目录(Window directory)中快速创建所有文件和文件夹的列表,并将其以易于查看的格式发送给某人。之前我曾写过如何使用命令行(command line)或第三方应用程序打印Windows 目录(Windows directory)中所有文件和文件夹的列表,但是,这些选项仅输出到文本、Word 或 Excel(Word or Excel)。
目录HTML
DirHTML是一个漂亮的程序,它几乎做同样的事情,生成文件和文件夹的递归列表,但将其输出为带有链接的HTML 表(HTML table)!因此,您实际上可以单击任何文件以在Web 浏览器(web browser)中打开该文件,或者使用该文件类型的(file type)默认应用程序(default application)打开该文件。这对于在本地网站上工作的 Web 开发人员来说可能非常方便。
下面(Below) 是在我的计算机上的下载文件夹中以HTML 格式(HTML)输出的目录列表(directory listing)的样子。您会注意到输出有点简单,(bit plain and kind)看起来有点老派。这是因为程序很旧,因此它创建的网页看起来很旧。如果您想要目录列表(directory listing)的更精美的输出,请查看我在下面提到的第二个名为Snap2HTML的程序。
顶部是锚点,它们是指向您指定目录中所有文件夹的链接。之后,将列出根文件夹内和根目录下每个文件夹内的所有文件及其基本文件属性。(root folder)您可以单击任何文件来打开它们。
下载程序后,只需运行dirhtml.exe文件,您将获得如下配置窗口(configuration window):
该程序是高度可配置的,但如果您不想做任何其他事情,您也可以只选择文件夹并单击“构建”按钮。(Build)您可以根据文件扩展名(file extension)(文件规范(File Specification))或文件名进行过滤。
在Miscellaneous下,您可以指定要包含在HTML 输出(HTML output)中的文件属性,并指定是否要在链接中使用完全限定的路径。如果您希望能够将文件/文件夹传输到另一台计算机,这将非常有用。您可以将该文件夹复制到同一路径下的另一台计算机上,即 C:My Documents\Test并且仍然可以单击HTML 列表(HTML listing)中的文件来打开它们。
在排序(Sorting)下,您可以选择按文件名(Filename)、大小(Size)、日期(Date)和扩展(Extension)名对文件进行排序。
您还可以配置程序以递归或不递归地构建目录列表。您可以选择是将所有链接放在一个HTML 文件(HTML file)中,还是为每个单独的文件夹创建一个HTML 文件(HTML file)。
总的来说,它是一个有用的程序,可以为Windows中的任何文件夹分支快速创建(folder branch)HTML 网页(HTML web)。
Snap2HTML
第二个程序Snap2HTML没有那么多选项,但输出看起来要好得多。这是我计算机上相同下载目录的HTML 输出:(HTML output)
该程序有一个非常简单的界面,只有几个选项。要运行该程序,只需双击 Snap2HTML.exe 文件。与DirHTML一样,该程序(program doesn)不需要安装。
首先,您选择要开始列出目录的(directory listing)根文件夹(root folder)。如果您愿意,有两个选项可以包含隐藏文件或系统文件。(hidden or system files)您可以更改HTML 页面(HTML page)的标题,如果您希望每个文件都是可点击的链接,可以选中链接文件(Link files)下的启用。(Enable)
您可以选中“就绪时在浏览器中打开”(Open in browser when ready)按钮,然后单击“创建快照(Create Snapshot)”以生成HTML 目录(HTML directory)列表。系统将提示您先保存HTML 文件(HTML file) ,然后它将在您的默认 Web 浏览器中打开。
因此,您有两个程序可以完成工作。每个都有自己的优点和缺点,所以请随意选择更适合您需求的那个。如果您有任何问题,请发表评论。享受!
Convert Windows Directory to HTML Listing
Εver need to create an HTML file that lists all the files and folders in a particular Windows directory? Probably not something you’ll need to do very often, but it does come in handy every once in a while.
For example, if you want to quickly create a list of all files and folders inside of a Window directory and send it to someone in a nice easy to view format. Earlier I had written about how you can use either the command line or third-party apps to print a list of all files and folders in a Windows directory, however, those options only output to text, Word or Excel.
DirHTML
DirHTML is a nifty program that pretty much does the same thing, generating a recursive list of files and folders, but outputs it as an HTML table with links! Therefore, you can actually click on any file to open the file in the web browser or with whatever the default application is for that file type. This could be very convenient for web developers working on a website locally.
Below is what a directory listing outputted in HTML looks like for the download folder on my computer. You’ll notice the output is a bit plain and kind of old-school looking. This is because the program is old and therefore the webpage it creates looks pretty old. If you want a fancier output for the directory listing, check out the second program called Snap2HTML that I mention below.
Across the top are anchors, which are links to all of the folders inside the directory you specified. After that, all files within the root folder and within each folder under the root are listed along with their basic file attributes. You can click on any of the files to open them.
Once you download the program, simply run the dirhtml.exe file and you’ll get a configuration window like this:
The program is highly configurable, but you can also just choose the folder and click the Build button if you don’t want to do anything else. You can filter based on file extension (File Specification) or by file names.
Under Miscellaneous, you can specify the file attributes you want to include in the HTML output and specify if you want to use fully qualified paths in the links. This is useful if you want to be able to transfer the files/folders to another computer. You can copy the folder to the other computer under the same path, i.e. C:\My Documents\Test and still be able to click on the files in the HTML listing to open them.
Under Sorting, you can choose to sort the files by Filename, Size, Date, and Extension.
You can also configure the program to build the directory listing recursively or not. You can choose whether you want all links in one HTML file or to create an HTML file for each separate folder.
Overall, it’s a useful program to quickly create HTML web pages for any folder branch in Windows.
Snap2HTML
The second program, Snap2HTML, doesn’t have as many options, but the output looks way better. Here is the HTML output for the same downloads directory on my computer:
The program has a very simple interface and just a couple of options. To run the program, just double-click on the Snap2HTML.exe file. Like DirHTML, this program doesn’t require an installation.
First, you pick the root folder you would like to start the directory listing with. There are two options to include hidden or system files if you like. You can change the title of the HTML page and you can check Enable under Link files if you want every file to be a clickable link.
You can check the Open in browser when ready button and then click Create Snapshot to generate the HTML directory listing. You’ll be prompted to save the HTML file first and then it will open in your default web browser.
So there you have two programs that get the job done. Each has it’s own pluses and minuses, so feel free to pick the one that suits your needs better. If you have any questions, post a comment. Enjoy!