1

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?

Thank you

mklement0
  • 382,024
  • 64
  • 607
  • 775
  • 2
    might be of interest: https://github.com/santisq/PSTree – Santiago Squarzon Aug 14 '23 at 20:01
  • 2
    [https://learn.microsoft.com/de-de/windows-server/administration/windows-commands/tree](https://learn.microsoft.com/de-de/windows-server/administration/windows-commands/tree) – Olaf Aug 14 '23 at 20:11
  • 2
    Have you tried to take a look to the help? `tree /?` – Olaf Aug 14 '23 at 20:12
  • @Olaf - Thank you, tree /F works, it shows all files, also hidden file, such as .gitignore, but do not show hidden folder, such as .git, but it has solved my problem. thank you – Stefan Glova Aug 14 '23 at 20:34
  • The Windows `tree.com` utility _never_ shows _hidden_ file-system items (irrespective of whether they're files or directories). On Windows, a name starting with `.` does _not_ make an item hidden - it is solely the `Hidden` file/directory _attribute_ that controls default visibility. – mklement0 Aug 14 '23 at 22:14

1 Answers1

2

tree.com:

  • does have an option to include files in the output: /F

  • does not have an option to include hidden directories and files - they are invariably excluded.[1]


Solutions:

  • This answer contains an custom PowerShell function named tree that extends the functionality of tree.com and whose -Force switch allows you to include hidden items.

  • The Get-PSTree cmdlet from the third-party PSTree module (install with, e.g., Install-Module PSTree) also supports -Force and offers even more features.


[1] I'm referring to files and directories on Windows that have the Hidden attribute, which is unrelated to whether their names start with . (e.g., .gitignore; it is only on Unix-like platforms that the latter are automatically considered hidden). You can set the Hidden attribute with attrib +H someDir, for instance, and clear it with attrib -H someDir. tree.com does not show such hidden items.

mklement0
  • 382,024
  • 64
  • 607
  • 775