您(Did)是否曾经需要从特定文件夹中导出整个目录树?(directory tree)您(Did)是否需要获取一个文本或 Excel 文档(text or Excel document),将计算机中特定文件夹内的所有文件和文件夹按层次结构列出?当我们试图创建一个文档时,我们就有了这种需求,该文档应该是我们存储在文件夹中的所有Word文档和Excel电子表格的摘要。(Excel)正是在那个时候,我们问了自己几个问题。您可以自动将文件夹的结构导出到Excel吗?是否有输出到文件的 DOS树命令?(tree)你能打印一个目录树吗(directory tree)放入Excel 工作表(Excel sheet)或作为文本文件(text file)?如果您想了解如何导出文件夹树(folder tree),请继续阅读:
注意:(NOTE:)我们有两种方法可用于导出文件夹的树。第一个基于使用命令提示符(Command Prompt)并将目录树生(directory tree)成为文本文件(text file)。第二个依赖于我们使用PowerShell创建的可执行文件,并将(PowerShell)文件夹树(folder tree)输出为Excel 文件(Excel file)和CSV 文件(CSV file)。
1. 使用命令提示符(Command Prompt)中的“树(Tree)”命令将文件夹的结构导出到文本文件(text file)
首先是打开文件资源管理器并导航(File Explorer and navigate)到要为其导出目录树(directory tree)的文件夹。在我们的例子中,这将是“D:Games”。
在文件资源管理器的(File Explorer's)地址栏中输入 cmd 并回车,(cmd)直接(Enter)在您感兴趣的文件夹中打开命令提示符。(Command Prompt)
打开一个命令提示符(Command Prompt)实例,指向您的文件夹。在我们的例子中,命令提示符(Command Prompt)是使用“D:Games”文件夹打开的。要导出文件夹的结构,请运行以下命令:tree /a /f > output.doc。
提示:(TIP:)如果您不希望目录树(directory tree)包含文件(换句话说,使目录树只包含文件夹),请跳过命令中的/f参数(tree /a > output.doc)。
Output.doc是将保存整个目录树的(directory tree)文档文件(document file)。您可以使用任何名称,也可以指定任何文件类型(file type),只要它具有文本文件类型(text file type)。我们更喜欢使用Microsoft Word .doc文件,但您可以使用任何其他文本文件(text file)。例如,您可以选择将目录树输出到可使用(directory tree)记事本(Notepad)编辑的简单.txt文件。根据文件夹中存储的文件夹和文件的数量,运行此命令可能需要一两分钟。
现在您可以关闭Command Prompt,因为您不再需要它了。返回文件资源管理器(File Explorer)并导航到要为其导出目录树(directory tree)的文件夹。在内部(Inside),您应该会找到具有您在tree命令中指定的名称的新文本文件。(text file)在我们的例子中,这个文件被称为output.doc。
打开输出(output)文件,里面列出了整个目录树。(directory tree)看起来不错,不是吗?
注意:(NOTE:)如果要导出包含系统文件或文件夹的文件夹的目录树,则必须以管理权限启动命令提示符(Command Prompt),然后从命令提示符(Command Prompt)本身导航到您的文件夹。
2.使用我们的 FolderTree 工具(基于PowerShell)将文件夹的结构导出到Excel 或 CSV 文件(Excel or CSV file)
在Windows 10(Windows 10)中导出文件夹结构的另一种简单方法是使用我们为您创建的名为FolderTree的工具。使用此链接(using this link)或本节末尾的链接下载它。将其保存在 Windows 10 PC 上的某个位置。然后,将其移动或复制(move or copy)到您要为其获取树结构(tree structure)的文件夹中。在该文件夹中,双击或双击FolderTree可执行文件。
当您第一次启动FolderTree时,SmartScreen 过滤器(SmartScreen filter)会警告您它是一个无法识别的应用程序。那是因为没有那么多人下载和使用它。相信它是安全的,不会损害您的 PC。它只不过是可执行文件中的PowerShell脚本和简单的用户界面。为了能够使用此工具,请单击或点击(click or tap)“更多信息”("More info"),然后选择“仍然运行”。("Run anyway.")
当FolderTree打开时,您应该会看到一个如下所示的小窗口。要获取当前文件夹的目录树,请按下(directory tree)“Get folder tree to Excel”按钮。
然后该工具会输出两个文件:FolderTree.xlsx和FolderTree.csv。两者都包含当前目录中的文件夹和文件的树状列表。
此外,两个文件都应该有两列:Directory和Name。Directory告诉您文件夹,Name告诉您该文件夹中的文件。
现在,您可以根据需要使用文件夹树编辑(folder tree)Excel 或 CSV 文件(Excel or CSV file)。如果您在使用我们的工具时遇到任何问题,请在下面的评论部分告诉我们。
下载:(Download:) 文件夹树(FolderTree)
您为什么想知道如何导出文件夹的目录树?
在Windows中可以快速将整个目录树结构(directory tree structure)导出到文本文件(text file)。您所需要的只是命令提示符(Command Prompt)和正确的命令。(All)如果您使用我们的FolderTree(FolderTree)工具,将目录树(directory tree)导出到Excel也很容易。在结束本文之前,请告诉我们您为什么要创建文件夹树(folder tree)?是因为你想列出你的音乐文件吗?是为了与工作相关的任务吗?在下面发表评论(Comment),让我们讨论。
How to export the directory tree of a folder in Windows
Did you ever need to export the entire dіrectory tree from a partiсular folder? Did уou need to get a text or Excel document that lists all the files and folders іnѕіde a specific folder from your comрuter into a hіerarchicаl ѕtructure? Wе had this need when we were trying to create a document that was supposed to be a summary of all the Word documents and Excel spreadshеets we had ѕtored insidе a fоlder. It was at that time that we aѕked ourselves a cоuple of questions. Can you automatically export a folder's strυcture to Excel? Is there a DOS tree command that outputs to a file? Can you print a directory tree into an Excel sheet or as a text file? If you want to find out how to export a folder tree, read on:
NOTE: We have two methods that you can use to export a folder's tree. The first one is based on using the Command Prompt and generates the directory tree as a text file. The second relies on an executable file that we created with PowerShell and outputs the folder tree as an Excel file and as a CSV file.
1. Export a folder's structure to a text file, using the "Tree" command in Command Prompt
The first thing is to open File Explorer and navigate to the folder for which you want to export the directory tree. In our case, that would be "D:Games."
Type cmd in File Explorer's address bar and press Enter to open the Command Prompt directly at the folder you are interested in.
A Command Prompt instance is opened, pointing to your folder. In our case, the Command Prompt was opened using the "D:Games" folder. To export the folder's structure, run this command: tree /a /f > output.doc.
TIP: If you don't want the directory tree to include files (in other words, make the tree include only folders), skip the /f parameter from the command (tree /a > output.doc).
Output.doc is the document file in which the entire directory tree is going to be saved. You can use any name for it, and you can specify any file type, as long as it has a text file type. We prefer using Microsoft Word .doc files, but you could use any other text file. For instance, you can choose to output the directory tree to a simple .txt file that's editable with Notepad. Depending on how many folders and files are stored inside your folder, running this command can take a moment or two.
Now you can close the Command Prompt, as you don't need it anymore. Go back to File Explorer and navigate to the folder for which you wanted to export the directory tree. Inside, you should find the new text file with the name you specified in the tree command. In our case, this file is called output.doc.
Open the output file and the entire directory tree is listed inside. It looks good, doesn't it?
NOTE: If you want to export the directory tree of a folder that contains system files or folders, you must launch Command Prompt with administrative rights and then navigate to your folder from the Command Prompt itself.
2. Export a folder's structure to an Excel or CSV file, using our FolderTree tool (based on PowerShell)
Another easy way to export the structure of a folder in Windows 10 is to use a tool that we created for you, called FolderTree. Download it using this link or the one at the end of this section. Save it somewhere on your Windows 10 PC. Then, move or copy it to the folder for which you want to get the tree structure. In that folder, double-click or double-tap on the FolderTree executable.
When you launch FolderTree for the first time, the SmartScreen filter warns you that it is an unrecognized app. That's because there are not that many people downloading and using it. Take our word that it's safe and does not harm your PC. It is nothing more than a PowerShell script inside an executable file and a simple user interface. To be able to use this tool, click or tap on "More info" and then choose to "Run anyway."
When FolderTree opens, you should see a small window like the one below. To get the directory tree of the current folder, push the "Get folder tree to Excel" button.
The tool then outputs two files: FolderTree.xlsx and FolderTree.csv. Both contain the tree list of folders and files inside your current directory.
Furthermore, both files should have two columns: Directory and Name. Directory tells you the folder, and Name tells you the files in that folder.
Now you can go ahead and edit the Excel or CSV file with your folder tree as you want. If you encounter any issues with our tool, let us know in the comments section below.
Download: FolderTree
Why did you want to know how to export the directory tree of a folder?
Exporting the entire directory tree structure to a text file is quickly done in Windows. All you need is the Command Prompt and the right command. Exporting a directory tree to Excel is also easy if you use our FolderTree tool. Before closing this article, tell us why you wanted to create a file folder tree? Was it because you wanted to make a list of your music files? Was it for a work-related task? Comment below and let's discuss.