In Windows 10, For easy understanding, each drive is assigned with a letter. (Eg.-C:\ drive). Similarly, Folder is a directory structure where files are stored for organizational purpose. But for system and user to understand the hierarchical structure of a folder, we need to create tree directory structure in a file. By referring to this directory structure, you will get the understanding of files , setup files/other files and any sub-folders present inside the folder. It can be achieved in 2 ways. Lets see how to do it. This article will guide you in simple steps.
Method 1: How to get Tree directory structure through Command Prompt.
Step 1: Press Winkey and Type cmd.
Click “Run as administrator“.
After command prompt opens, Execute this command.
tree d:\thegeekpage /a /f > d:\directoryList.txt
Here you have created a folder tree directory structure. you can see the text file directorylist.txt being created in the D:\ drive.
Open this file with notepad and you can see as shown below.
Here , thegeekpage folder has subfolder ( harddriveoff ) which in turn has 4 png files.
So the tree structure helps to read easily.
Method 2: Using Powershell we can create Tree directory structure.
Step 1: In order to open Powershell, Press WinKey + X and select Windows Powershell as shown.
Step 2: Run this following command.
Get-ChildItem -Recurse 'd:\thegeekpage' | Select-Object FullName, name | Export-Csv -path d:\thegeekpageList.csv -noTypeInfo
where you need to replace “d:\thegeekpage” with the path to your folder and also replace “d:\thegeekpageList.csv” with the output file path.
Step 3: After executing the above step.
You can see thegeekpageList csv file get generated in the specified drive which shows like this.
Here you will see all the folders that are present and also all the files inside those folders in a hierarchical structure.
Hope you got to learn how to get tree directory structure in simple way.
Thank you!