Windows – How to recursively list files (and only files) in windows command propmpt

command linewindows 7

Wanted:

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

I DON'T wont 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

Best Answer

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

enter image description here

enter image description here

Related Question