Change Drives To change to another disk drive, key in the drive letter ( ‘A’, ‘C’, ‘D’, etc) followed by a colon (‘:’) then press the <Enter> key.
Change Drives The DOS Prompt should now look like the following. Drive A: is now the current default drive.
The DIR Command • We have a directory full of disk files • How do we look at what is on the disk or what files are in a directory? • What is a directory anyway? • Use the DIR command
At the top Volume label serial number drive (and directories) DIR Command
For each file file name file extension file size (in bytes) file date(created or last modified) file time(created or last modified) at the bottom # of files bytes used # of directories bytes available The DIR Command Shows
DIR Command Options • /P pause after displaying a page • /W display ‘wide’ (five files per column) • /X includes short filenames • Change Sort Order • /O - alpha by main file name then extension • /ON - alpha by main file name • /OE - alpha by extension • /OEN - alpha by extension, then main name • /OD - by date and time • /OS - by size • Alternate format /O:S
EXAMPLES • Insert your DATADISK in drive A • List all files alphabetically by file name • Find the smallest file • Find the oldest file • How many files have an “.LST” extension • How many files are there on the disk • How many files have 1~299 bytes (size) • How many files do not have an extension
A note on the order switch • You can reverse the order of the optional parameter of the ‘sort order’ switch (pg 48). • If you put a dash ‘-’ in front of the optional parameter, the order is reversed. • Examples: • A:\>DIR /OE A:\>DIR /O-E • A:\>DIR /OS A:\>DIR /O-S
wildcards and the DIR • When you enter DIR you get all files in that directory listed for you. • There are 2 wildcards that allow you to select the files to be listed • ? Replaces a single character • * replaces a number of characters
The * wildcard • DIR lists all files in that directory • DIR PA* lists all files starting with ‘PA’ • DIR *T lists all files ending with an ‘T’ • DIR A*LS lists all files starting with an ‘A’ and ending with an ‘LS’ • DIR *.PPT lists all files with a .PPT extension • DIR *T.* lists all files where the last letter of the file name (not the ext) is “T”
Using your DATADISK • How many files start with a “P”? • How many files have an extension of “XLS”? • How many files have an extension that starts with “W”? • How many file names start with “INV”? • How many files have an “SU” somewhere in their file name (not extension)?
The ? wildcard • The ? replaces a single character DIR PALETTE???.BMP lists all files that start with ‘PALETTE’, then any 3 characters, then ‘BMP’ • DIR “PALETTE ??.BMP” lists all files starting with ‘Palette[space]’, then any 2 characters, then ‘BMP’. • What happens if you try it without the quotes?
Using your DATADISK • How many files have an “N” as the second letter of their file name? • How many files have a 3 character extension that starts with “PP”? • How many files have a “FT” in the 3rd and 4th letters?
Default Switches • DOS saves important settings in a memory area called the DOS ENVIRONMENT • to see the environment, key in: A:\>SET • the env. variable for DIR is DIRCMD • to change the settings, key in: A:\SET ‘environment variable”=string • to set DIR commands enter (example) A:\SET DIRCMD=/P/O • now again, key in A:\>SET
Attributes • DIR /AH Hidden files • DIR /AR Read only • DIR /AS System files • DIR /AA Archive files - not backed up