Skip navigation

JSI Tip 0651 - Using the DIRCMD environment variable.

The DIR command has many switches (type DIR /?):

dir \[drive:\]\[path\]\[filename\] \[; ...\] \[/p\] \[/w\] \[/d\] \[/a\]attributes\[/o\]sortorder \[/t\]timefield \[/s\] \[/b\] \[/l\] \[/n\] \[/x\]
If you regulary type switches and have a favorite set that you use, you can cause the DIR command to remember them by setting the DIRCMD environment variable:

set DIRCMD=/b /o:-n

causes DIR to always use the /b and /o:-n switches. You can override these defaults for a given invocation of DIR:

DIR \[drive:\]\[path\] /-b

will perform the above dir without the /b switch but will still use the /o:-n switch.

You should set the DIRCMD environment variable in Control Panel / System / Environment.

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.