Formatting Directory Listings

Although the OS/2 Command Reference page lists all of the parameters for the dir command, there are so many of them that I thought that I would go through them in more detail. Also something not mentioned on that page is that you can change the default parameters for the dir command by adding set dircmd= into the config.sys file and appending the parameters that you want to have as defaults there.

Let's begin with the /a parameter. This parameter changes the list of file attributes that files can have and be included in the list. The options for this parameter are:

Note that options included in parameters need to be typed immediately after the parameter without any spaces for example: /a+a+h+r+s to include all files.

The /b parameter removes the headers and footer summary information from the output making for a slightly smaller result. This is particularly useful when you are feeding the output into another process as each entry will represent an actual file or folder.

The /f parameter will include the full path in all of the filenames in the listing.

To change all of the filenames in the output to lower case you need to use the /l parameter.

Normally FAT partitions display their directory listings in a different format to that used by HPFS partitions. To force all listings to display using the HPFS format use the /n parameter. This will cause long file names to be displayed in the listing for files on FAT partitions.

The resultant listing can often be longer than the number of lines on the screen. To resolve this you can use the /w parameter to use wide format which places several entries on each line and/or the /p parameter which will pause the output after the screen is filled and wait for you to press a key before continuing.

The /s parameter can be used to expand the listing to show not only the files in the selected directory but also those in any sub-directories of that directory.

The most useful of the parameters is the /o parameter which can be used to change the order in which the listing displays. Each of the following options can be used to set the sort sequence:

These parameters can be added to any dir command or (as I mentioned earlier) entered in the set dircmd= command in your config.sys file so as to default to that option without having to specify it on every command. Of course if you do that you will need to place the appropriate overriding parameter on the command when you don't want your default to apply.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow