DIR – Windows CMD Command

Display a list of files and subfolders.

The switches above can be preset by adding them to an environment variable called DIRCMD.
For example SET DIRCMD=/O:N /S

Override any preset DIRCMD switches by prefixing the switch with –
For example DIR *.* /-S


The default Sort Order, if you don’t specify anything with /O, on an NTFS drive will be in sort-of-alphabetical order or on a FAT USB thumb drive, then the order will be based on the order in which files were created and deleted and the lengths of their names.

Upper and Lower Case filenames:

Filenames longer than 8 characters – will always display the filename with the mixed case as entered.
Filenames shorter than 8 characters – can display the filename in upper or lower case – this can vary from one client to another (registry setting)

Listing the full path

The command DIR /b will return just a list of filenames, when displaying subfolders with DIR /b /s the command will return a full pathname.

If you want to list the full path without including subfolders, use the FOR command as in this example script.


If the file(s) were successfully listed %ERRORLEVEL% = 0
If the file was not found or bad parameters are given %ERRORLEVEL% = 1

All file sizes are shown in bytes.

DIR is an internal command.

You may also like...

3 Responses

  1. 사설토토 says:

    Wow, superb blog layout! How long have you been blogging for? you make blogging look easy. The overall look of your site is wonderful, as well as the content!

  2. опрессовка says:

    Good article! We will be linking to this great post on our website.
    Keep up the good writing.

  3. zoritoler imol says:

    Howdy would you mind stating which blog platform you’re using? I’m going to start my own blog in the near future but I’m having a hard time selecting between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your layout seems different then most blogs and I’m looking for something completely unique. P.S My apologies for getting off-topic but I had to ask!

Leave a Reply

Your email address will not be published. Required fields are marked *