I'm trying to use DIR to list all files in the current directory and sub directories ordered alphabetically. I only care about the filepath and name. I don't want the size, counts, etc. Here's what I have but it's just too details:

dir/on/s/w/a-d > __files.txt

This outputs something like (obfuscated):

 Volume in drive Q is ********
 Volume Serial Number is ****-****

 Directory of Q:\****

__files.txt                    __listallfileswithoutput.bat
               2 File(s)             28 bytes

 Directory of Q:\****\*

*** ****.***           ******.***              ** **** ******.***
** **** ** ******.***   
               4 File(s)  4,288,735,526 bytes

 Directory of Q:\****\*


I just want:

Q:\****\*\*** ****.***
Q:\****\*\** **** ******.***
Q:\****\*\** **** ** ******.***

Can this be done with DIR alone? If not, how can it be done?


Is the output of dir/on/s/a-d/b > __files.txt what you expect?

  • Yes, that's exactly what I want. You should expand your answer to include the reasons why/how it works. FYI, I looked through the DIR help and completely overlooked /b! Thanks – Paul Fleming Dec 24 '12 at 15:56
  • Not sure what sort of reasons/explanation you're looking for, that a simple dir /? will not provide. /on sorts by name (alphabetic), /s is for dir recursion, /a-d omits dirs and /b is for a bare output format. The rest simply redirects the command's output to your chosen file. – Karan Dec 24 '12 at 15:59

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.