32

Wanted:

I want a listing of files with full paths listed out recursively in Windows 7 through the command prompt.

I DON'T want folders to be listed.

Attempt:

This got me all files, but also included the directories:

dir /b /a /s

Result:

C:\path1
C:\path1\file1.txt
C:\path1\path2
C:\path1\path2\file2.txt

Desired Output:

C:\path1\file1.txt
C:\path1\path2\file2.txt

Other Thoughts:

I'm thinking I could do a loop (here's some psuedo-code):

for /f %a in ('dir /b /a /s') do if something then @echo %~a endif

2
  • What OS are you using?
    – Ramhound
    Dec 7, 2015 at 18:53
  • I'm using WIndows 7
    – ScrappyDev
    Dec 7, 2015 at 18:58

1 Answer 1

51

dir /A-D /S /B will produce the result you want:

enter image description here

C:\>dir /?
(...)
/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             O  Offline files
             -  Prefix meaning not
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .