How to get a list of folders and subfolders without files?

I am trying to print a list of folders and subfolders of a directory into a file.

When I run dir/s/b/o:n > f.txt , I also get a list of files. I only need folders and subfolders.

Does anyone know if this is possible to do from the command line interface?

+67
directory cmd folder subdirectories dir
Apr 18 '13 at 8:49
source share
4 answers

Try the following:

 dir /s /b /o:n /ad > f.txt 
+122
Apr 18 '13 at 9:59 on
source share
  Displays a list of files and subdirectories in a directory. DIR [ drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sortorder]] [/P] [/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4] [drive:][path][filename] Specifies drive, directory, and/or files to list. /A Displays files with specified attributes. attributes D Directories R Read-only files H Hidden files A Files ready for archiving S System files I Not content indexed files L Reparse Points - Prefix meaning not 

just set the type of the desired file attribute, in your case / A: D (directory)

dir / s / b / o: n / A: D> f.txt

+19
Apr 18 '13 at 8:53 on
source share

I used dir /s /b /o:n /a:d and it worked fine, just make sure you allow the file to write, or you will have an incomplete list.

+4
May 28 '15 at 16:14
source share

dir/ad/b/s will give the required answer.

+1
Oct 10 '14 at 11:57
source share



All Articles