Microsoft

Is the DIR command a thing of the past?


I was recently playing around in DOS and started fooling around with the DIR switches. Using the command prompt is still a great way to perform file management tasks. Witht the DIR command, you can list short and long filenames with plenty of details. One switch I find helpful is the /B switch; it lists long filenames and no details. You can also combine switches as needed. You can access the switch menu by typing the following:

dir /?

The output is the following:

DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N]

  [/O[[:]sortorder]] [/P] [/Q] [/R] [/S] [/T[[:]timefield]] [/W] [/X] [/4]

  [drive:][path][filename]

              Specifies drive, directory, and/or files to list.

  /A          Displays files with specified attributes.

  attributes   D  Directories                R  Read-only files

               H  Hidden files               A  Files ready for archiving

               S  System files               I  Not content indexed files

               L  Reparse Points             -  Prefix meaning not

  /B          Uses bare format (no heading information or summary).

  /C          Display the thousand separator in file sizes.  This is the

              default.  Use /-C to disable display of separator.

  /D          Same as wide but files are list sorted by column.

  /L          Uses lowercase.

  /N          New long list format where filenames are on the far right.

  /O          List by files in sorted order.

  sortorder    N  By name (alphabetic)       S  By size (smallest first)

               E  By extension (alphabetic)  D  By date/time (oldest first)

               G  Group directories first    -  Prefix to reverse order

  /P          Pauses after each screenful of information.

  /Q          Display the owner of the file.

  /R          Display alternate data streams of the file.

  /S          Displays files in specified directory and all subdirectories.

  /T          Controls which time field displayed or used for sorting

  timefield   C  Creation

              A  Last Access

              W  Last Written

  /W          Uses wide list format.

  /X          This displays the short names generated for non-8dot3 file

              names.  The format is that of /N with the short name inserted

              before the long name. If no short name is present, blanks are

              displayed in its place.

  /4          Displays four-digit years

Poll.

8 comments
cl91447
cl91447

Sense I started with cmp/2 on a kaypro4 and then dos 3.1 I still use the old DIR and other commands. Much younger users often ask "How did you know to do that!" I'm showing my age (my wife say's am 61 going on 10) Thank you for these articals. Carl Lukers CL91447@hotmail.com (now you know my name and Birthday don't forget me)

Gudufl
Gudufl

Like I quoted, in another post, from a Forum contributor: If you dont know DOS, you dont know Windows...

NickNielsen
NickNielsen

Neither is the command line. I commonly open command sessions to search for files (DIR drive:filename.ext /s) without all the graphical bs, export directory listings to file (DIR drive:\path > drive:\filename.ext), obtain local network information (ipconfig /all), and many more. Some things are just easier from the command line. Edit: / to \. Been working in Linux a bit lately... :)

mjd420nova
mjd420nova

I still have a couple of users with DOS loaded. They are used for some large automated sampling systems. I have one system that's running PC-DOS 7.0 and is used in a home security system. Runs the data collection faster using RS-232 interface cards reading data inputs from ADC devices to collect inputs from infra-red, ultra-sonic Current loops and particulate detectors. The DIR command comes in very useful to look at data logging times so I can see sequential events.

DanLM
DanLM

At work, we have a number of scripts that are run from dos instead of a gui just because they are faster. I'm speaking of pl/sql scripts. So, absolutely. I use the dos prompt every day. Dan

KeReleaseSpinLock
KeReleaseSpinLock

Rather, a single command shell window in Windows. To run real DOS 6.22 for example, run up a virtual machine and load DOS. Yes, I have the actual Floppy install disks! :-)

CharlieSpencer
CharlieSpencer

Posting your address on the Internet exposes you to spammers. If you wish to be able to receive e-mail from other TR members, consider enabling your account to receive peer mails. Click on 'My Workspace' in the upper right, then the Profile tab, then the 'Edit Profile' button. Go to the bottom and click the button beside "Allow other TechRepublic members to contact me."

MartMan
MartMan

I have been scripting everything in sight for the last 8 years, and I still use the command line daily, especially things like dir. Doing things like the following are just quicker and better than writing a script for it: dir 2007*.log | find /i "error" | find /i "sql" > sqlerrors.log Regards.. Marty Editor TheScriptLibrary.com

Editor's Picks