You can use the tree command in PowerShell to display the folder structure of a particular directory:
By default, the tree command only shows the names of folders.
However, you can add the /f parameter to also display the names of the files in each folder:
- c:\users\bobbi\data1
Suppose we use the tree command to view the folder structure of our current directory:
There are three folders inside of the data1 folder named athletes, coaches and managers.
Notice that only the folder names are shown and no files within the folders.
We can use the /f parameter to show the file names as well:
Notice that the output now shows the folder names along with the files inside of each folder.
- new_data.txt
- old_data.txt
- records.txt
And so on.
Note: You can find the complete documentation for the tree command in PowerShell here.
PowerShell: How to Sort Files in Folder by Size
PowerShell: How to Get Folder Size in GB
PowerShell: How to List Files in Directory by Date
PowerShell: How to Get Most Recently Modified File in Directory
Active Directory Tree View
This sample creates a tree view of the OUs within Active Directory.
I am trying to get full structure of my project in tree format in powershell.
When I use the command tree
, it only shows directories and subdirectories, but neither files nor hidden folders, such as .git
How can I show files as well?
67 gold badges672 silver badges861 bronze badges
asked Aug 14, 2023 at 19:57
does have an option to include files in the output:
/F
answered Aug 14, 2023 at 20:25
67 gold badges672 silver badges861 bronze badges