280 likes | 395 Views
Chapter 2. Command Syntax. Command Syntax. Word order Punctuation. command name [variable parameters] [fixed parameters]. Examples: DIR A: /W DISKCOPY A: A: XCOPY A:* C:WUGXP /S/E/V. Parameters. What are parameters Information that modifies a command Variable parameters
E N D
Chapter 2 Command Syntax G. DeRoest
Command Syntax • Word order • Punctuation command name [variable parameters] [fixed parameters] Examples: DIR A:\ /W DISKCOPY A: A: XCOPY A:\* C:\WUGXP /S/E/V G. DeRoest
Parameters • What are parameters • Information that modifies a command • Variable parameters • Information that is user defined • Fixed Parameters • Information that the operating system pre-defines • Defaults • Parameters that commands will use if no others are specified G. DeRoest
Command Syntax • MS-DOS commands are flexible – they can be used to perform several tasks. • A command can be augmented by using parameters • There are two types of parameters • Variable • Fixed A:\> DIR A:\> DIR letter.doc A:\> DIR /W A:\> DIR letter.doc /W G. DeRoest
Reading a Syntax Diagram DATE [/T | date] A:\> DATE A:\> DATE /T A:\> DATE 05/14/2003 G. DeRoest
Reading a Syntax Diagram CD [drive:][path] A:\> CD A:\> CD letters A:\> CD A:\letters A:\> CD .. G. DeRoest
Reading a Syntax Diagram If drive and directory are not defined, then the defaults are used. REN [drive:][path]filename1 filename2 A:\> REN mytext.doc yourtext.doc A:\> REN A:\file1.txt file2.txt A:\> REN C:\letters\memo.pdf “my memo.pdf” G. DeRoest
Reading a Syntax Diagram DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N][/O[[:]sortorder]] [/P] [/Q] [/S] [/T[[:]timefield]] [/W] [/X] [/4] G. DeRoest
Fixed Parameters with DIR Command • DIR /P • DIR /W • DIR /P /W • DIR /OD • DIR /O-N • DIR /S • DIR /? • See page 848 for printed version G. DeRoest
Variable Parameters • Variable parameters are usually used to identify a drive, directory, and/or file name or names A:\> DIR jan.99 A:\> DIR steven.fil A:\> DIR c:\winnt\system32\*.exe G. DeRoest
DOS File Names • All files within a directory must have a unique name • Names are required and may be less than 255 characters • File extensions art usually 3 characters long • Names cannot contain :“/\|<>*? G. DeRoest
File Names with Spaces • DIR “Sandy and Patty.txt” G. DeRoest
8.3 File Names DIR SANDYA~1.TXT G. DeRoest
Command Line Editing G. DeRoest
Command Line Editing G. DeRoest
Drives and Device Names • A: • B: • C: • D: • E: • F: • G: • ... G. DeRoest
Changing Defaults • Default drive: • A: C: G: • Default directory: • cd \ • cd \windosbk • cd “\program files” G. DeRoest
Variable Parameters with DIR Display the list of files in the default directory of drive A: • C: • CD \ • DIR A: • DIR HELLO.TXT • DIR A:HELLO.TXT Look in the default directory of the default drive Display file in the default directory of drive A: G. DeRoest
Changing Directory • C: • CD • CD \ • CD \WINNT\SYSTEM32 • DIR /W G. DeRoest
Directory Structure \ B winnt files apps A C D local money game E G F G. DeRoest
Changing Directory • A: • CD \MEDIA • CD \MOVIES • CD \MEDIA\MOVIES • CD MOVIES G. DeRoest
Wildcards • Used to define a group of filenames • One or more characters * • One or zero character ? G. DeRoest
DIR and Wildcards • C: • CD \WINNT\SYSTEM32 • DIR P • DIR P*.* • DIR P* • DIR P*.EXE • DIR *.SYS G. DeRoest
DIR and Wildcards • DIR A:\?????.TXT • DIR A:\?????.* • DIR A:\?????. G. DeRoest
Redirection Tools to define where the output of a command will display. COMMAND>DESTINATION G. DeRoest
Redirection Examples • A: • DIR *.NEW • DIR *.NEW > MY.HW • DIR MY.HW G. DeRoest
Redirection Examples • ECHO GARY • ECHO GARY > PRN • ECHO GARY > LPT1 • ECHO GARY > LPT2 G. DeRoest
DIR /? C:\>dir /? Displays a list of files and subdirectories in a directory. DIR [drive:][path][filename] [/A[[:]attributes]] [/B] [/C] [/D] [/L] [/N] [/O[[:]sortorder]] [/P] [/Q] [/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 - 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. /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 Switches may be preset in the DIRCMD environment variable. Override preset switches by prefixing any switch with - (hyphen)--for example, /-W. G. DeRoest