How to recursively list files (and only files) in Windows Command Prompt?

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

1 Answer

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

enter image description here

enter image description here

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like