In Windows CMD, I use tree c: /f to get a tree of all directories resided in C:. But now I only want to tree out the only sub-directory folders (not files). How to I exclude files in tree command?
- 1,939
- 9
- 32
- 43
4 Answers
Leave out the "/F" switch, since it's what causes Files to be included.
From tree /?:
Graphically displays the folder structure of a drive or path.
TREE [drive:][path] [/F] [/A]
/F Display the names of the files in each folder.
/A Use ASCII instead of extended characters.
- 111,883
- 19
- 201
- 268
-
1beat me to it... – Lamar B Dec 29 '11 at 03:09
-
@Ƭᴇcʜιᴇ007 Is there a way we can print this output to text or other file – Pravin W Dec 01 '15 at 07:29
For Mac/Ubuntu you can do...
tree -d directories only.
You might have to install it beforehand.
// Mac
brew install tree
// Ubuntu
sudo apt-get install tree
to output to txt file use command: (you will find in on drive C, as specified below)
tree /a > "C:\_TREE-Output.txt"
- 21
- 1
-
2This duplicates another answer and adds no new content. Please don't post an answer unless you actually have something new to contribute. – DavidPostill Mar 15 '16 at 09:55
-
2It does provide more information though, there's the "store in file" with `>` part that the other answer doesn't have. – sokkyoku Aug 31 '16 at 09:31
The command tree works for showing all files and folders on Windows. The command tree -d does directories only on Windows. So yes, it does work.
Note: tree -a shows ALL FILES/DIRECTORIES, including hidden ones. You can combine them like this: tree -a -d in the terminal. This works on Git Bash and on Command Prompt but requires tree.exe placed in Git Bash's bin folder (C:\Program Files\Git\usr\bin). For more information on Tree's installation for Windows, see this article on installation.
Good luck and happy programming.
- 101
- 2