DIR — Display directory entries

Synopsis

DIR [/?] [/A[+|-]drash] [/S[+|-]drash] [/O[[+|-]ANEDSG]] [/T[acw]] [/L [number]] [/W [number]] [/LOCALFORMAT] [/UTC] [/COLOUR] [/MONO] [/OLDSRCDIR[+|-]] [/E/U/B/F/H/P/Q[+|-]] Filespecs

Options

/?
Display command syntax information.
/A
Select files by attribute.
/S
Recurse into subdirectories.
/E
Do not display non-fatal error messages.
/U
Do not display summary information.
/Q
Operate quietly.
/B
Display the output in "bare" format, without size, date, or attribute information.
/F
Display the full pathname of each file, not just the basename.
/H
Do not display the "." and ".." entries.
/L
Specify how names should be mangled, by specifying one of the following numbers:
0
Perform no conversion (default if /L not used).
1
Convert everything to lower case (default if no number supplied).
2
Convert everything to upper case.
3
Convert everything to mixed case.
4
Convert directories to upper case and files to lower case ("Petercase").
/N
Compatibility option. This option does nothing.

Note: This option is present for backwards compatibility only. Its use should be avoided. In future releases of the DIR command this option will be removed, since the standard meaning for this option of simulate execution has no applicability to the DIR command. It is only present to ease the transition to a DIR command that always uses the "new" style of display format that was introduced with IBM OS/2 version 1 (sic!).

/O
Specify a sort string that determines how the output should be sorted, comprising zero or more of the following characters (optionally preceded by '-' to reverse the sense):
A
Sort by name, treating digits as numbers.
D
Sort by date and time stamp (according to the /T option).
E
Sort by extension (the part of the name following the final full stop).
G
Sort by attribute (directories, then hidden and system files, then all other files).
N
Sort by name.
S
Sort by size.
/P
Pipe the standard output and standard error to a pager command.

Note: This option is present for backwards compatibility only.

/T
Specify which dates and times to display and to sort on, by specifying one or more of the following characters:
A
Display the last access date and time.
C
Display the creation date and time.
W
Display the last write date and time.

The dates and times are displayed in the order that they are specified. The default is the same as if /TW had been used.

/W
Display the output in "bare" format, without size, date, or attribute information, and displaying multiple columns per line. The optional number argument specifies the line width to use. If it is not specified, the width of the console (if standard output is a console) is used.
/X
Do not display the header and footer containing the label, serial number, and free space of the volume.
/MONO
Prevent colours from being used.
/COLOUR
Force colours to be used.
/LOCALFORMAT
Use the local country's date and time formats.
/UTC
Display date/time stamps in UTC rather than local time.
/OLDSRCDIR
Duplicate quirks of the 16-bit CMD supplied with IBM OS/2 with respect to source names.

Note

The DIR command produces values for the extended attribute sizes for files and directories that are different to that produced by the DIR command built in to the 16-bit CMD supplied with IBM OS/2. This is because the DIR command built into the 16-bit CMD supplied with IBM OS/2 is a 16-bit command, which obtains the EA sizes as they appear to 16-bit OS/2, whereas this DIR command is a 32-bit command, which obtains the EA sizes as they appear to 32-bit OS/2.

Description

The DIR command displays the directory entries of all files that match the given search wildcard specifications. If no wildcard specifications are supplied, the default is to display the entries in the current directory.

The DIR command first processes the contents of the CMD_DIR_INIT environment variable, if it has inherited one, as if it were a command tail, before processing any of the command tails that have been passed to it. This allows one to modify default options globally. (One can use command aliases or wrapper scripts to achieve the same effect.)

By default, the last write time, size, extended attribute size, attribute flags, and basename of the file are displayed.

If the /P option is specified, DIR will pipe its standard output and standard error through a pager command. The pager command is specified by the contents of the PAGER environment variable. If there is no PAGER environment variable, the MORE command is used as the default pager command.

DIR invokes the pager command indirectly, by passing it as an argument to the command interpreter given by the COMSPEC environment variable (defaulting to "CMD" if that environment variable does not exist). So, for example, the pager command could be a command script, or a built-in command, or a command pipeline.

If DIR detects that its standard output is neither a pipe nor a file, it will send escape sequences to its standard output to change the colour of directory entries as specified in the DIR_COLOURS environment variable. This can be overridden by using the /MONO and /COLOUR options, to explicitly force or prevent the use of these escape sequences respectively.

DIR matches the colouring rules using the base part of the filename and the file's attributes, and applies each rule in order until one matches. If none of the colouring rules in the DIR_COLOURS environment variable match a file, or if the DIR_COLOURS environment variable does not exist, DIR will send escape sequences to change to white on black. To override this, append a colouring rule with "*" as its wildcard specification to the end of the DIR_COLOURS environment variable.

If colouring is used, DIR will change to white on black at the end of each directory entry displayed. It will do this before sending the newline sequence in order to prevent unsightly results if the screen happens to scroll up when the newline is sent.


The 32-bit Command Interpreter is © Copyright Jonathan de Boyne Pollard. "Moral" rights are asserted.