Internal Commands Dos Notes
Internal Commands Dos Notes
Getting a Command Prompt DOS Navigating with DOS The DOS Search Path Running Programs from
CD, CHDIR COPY DEL, ERASE DIR MD, MKDIR RD, RMDIR REN, RENAME
Copying Files Deleting Files Listing Files Creating Directories Deleting Directories Renaming Files
Usage Files can be deleted by using the DEL or ERASE command. Command Syntax ERASE options filespec
DELETE options filespec
Options /P (Prompt)
Prompt for confirmation before deleting. (Default for *.*)
/Q
/S
/F
/A
(Attributes)
R S H A
Read-only attribute set System attribute set Hidden attribute set Archive attribute set
y y y y
-R -S -H -A
Read-only attribute cleared System attribute cleared Hidden attribute cleared Archive attribute cleared
Remarks
y y
The ERASE command is the same as the DEL command. The Filespec can be: o A file name (with extension.) The file will be deleted from the current directory. o A file spec with wildcards. All files matching the pattern will be deleted from the current directory. o A pathname including a file name. The designated file will be deleted. o A pathname including a file name with wildcards. All files matching the pattern will be deleted from the designated directory.
o
The help will vary, depending on the DOS version. With Windows NT 5.0 (2000),
Deletes one or more files. DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names names Specifies a list of one or more files or directories. Wildcards may be used to delete multiple files. If a directory is specified, all files within the directory will be deleted. Prompts for confirmation before deleting each file. Force deleting of read-only files.
/P /F
Delete specified files from all subdirectories. Quiet mode, do not ask if ok to delete on global Selects files to delete based on attributes R Read-only files S System files H Hidden files A Files ready for Prefix meaning not
If Command Extensions are enabled DEL and ERASE change as follows: The display semantics of the /S switch are reversed in that it shows you only the files that are deleted, not the ones it could not find.
CD COMMAND
Abstract The CD (or CHDIR) command can be used to change the current default directory of the default drive, or of another drive. Command Syntax CD [option] [pathspec] The pathspec can be an absolute or relative path. The pathspec can include a drive letter. The pathspec cannot include wildcards (* or ?). CHDIR [option] [pathspec] The command CHDIR is an alias for the command CD. Options /D (Drive)
Also change the default drive.
Semantics pathspec If no pathspec is specified, the current default directory will be displayed. If the pathspec includes a drive, the default directory of the designated drive is changed, but the default drive is not changed unless the /D option is included. option If no option is specified, the current default drive will not be changed. Remarks
y y
DOS maintains a separate default directory for each drive. Availability of switches will vary with the version of the operating system. The options given will work with most currently popular versions.
The help will vary, depending on the DOS version. With Windows NT 5.1.2600 (XP),
Displays the name of or changes the current directory. CHDIR [/D] [drive:][path] CHDIR [..] CD [/D] [drive:][path] CD [..] .. Specifies that you want to change to the parent directory.
Type CD drive: to display the current directory in the specified drive. Type CD without parameters to display the current drive and directory. Use the /D switch to change current drive in addition to changing current directory for a drive. If Command Extensions are enabled CHDIR changes as follows: The current directory string is converted to use the same case as the on disk names. So CD C:\TEMP would actually set the current directory to C:\Temp if that is the case on disk. CHDIR command does not treat spaces as delimiters, so it is possible to CD into a subdirectory name that contains a space without surrounding the name with quotes. For example: cd \winnt\profiles\username\programs\start menu is the same as: cd "\winnt\profiles\username\programs\start menu" which is what you would have to type if extensions were disabled.
Example - CD WINDOWS\SYSTEM32
CD WINDOWS\SYSTEM32
Example - CD
CD Y:\dev\perl
MD COMMAND
Abstract The MD (or MKDIR) command can be used to create a new directory on the current default drive, or on another drive. Command Syntax MD pathspec The pathspec can be an absolute or relative path. The pathspec can include a drive letter. The pathspec cannot include wildcards (* or ?). MD /? Display help for the MD command. MKDIR The command MKDIR is an alias for the command MD. Options
/?
Semantics pathspec If the pathspec includes new intermediate directories, they will be created. If the pathspec is relatve, the new path will be created in the currend directory. If the pathspec does not includes a drive, the new path will be created on the current default drive. Remarks
y
Availability of switches will vary with the version of the operating system. The options given will work with most currently popular versions. Command extensions are enabled by default on Windows 5 and higher.
MD /?
The help will vary, depending on the DOS version. With Windows NT 5.1.2600 (XP),
Creates a directory. MKDIR [drive:]path MD [drive:]path If Command Extensions are enabled MKDIR changes as follows: MKDIR creates any intermediate directories in the path, if needed. For example, assume \a does not exist then: mkdir \a\b\c\d is the same as: mkdir chdir mkdir chdir mkdir chdir mkdir \a \a b b c c d
Example - MD WINDOWS\SYSTEM32
MD WINDOWS\SYSTEM32
RD COMMAND
Abstract The RD (or RMDIR) command can be used to create a new directory on the current default drive, or on another drive. Command Syntax RD [Options] pathspec The pathspec can be an absolute or relative path. The pathspec can include a drive letter. The pathspec cannot include wildcards (* or ?). RD /? Display help for the RD command. RMDIR The command RMDIR is an alias for the command RD.
Options /Q (Quiet) Do not ask for confirmation before deleting directory contents. (Without the /Q option, the user will be asked to confirm deletion of a directory which is not empty.) /S (Subs) Remove the contents of the directory. (Without the /S option, only an empty directory can be removed.)
/?
Semantics pathspec If the pathspec includes intermediate directories, only the last directory the path will be deleted. Remarks
y
Availability of switches will vary with the version of the operating system. The options given will work with most currently popular versions. Command extensions are enabled by default on Windows 5 and higher.
The help will vary, depending on the DOS version. With Windows NT 5.1.2600 (XP),
Removes (deletes) a directory. RMDIR [/S] [/Q] [drive:]path RD [/S] [/Q] [drive:]path /S directory directory tree. /Q with /S Quiet mode, do not ask if ok to remove a directory tree Removes all directories and files in the specified in addition to the directory itself. Used to remove a
Example - RD /S /Q WINDOWS
RD /S /Q WINDOWS
Command Syntax COPY [options] source [file-options] [destination [file-options] ] Options /A (ASCII)
ASCII mode (file or global option)
/B
/V
Remarks
y y
Wildcards ("*", "?") can also be used for the filename itself (but not for the directories). The destination is optional. o If no destination is given, the destination will be the current default drive and directory. The destination can be a file name or a directory. o If the destination is a file name, the new file copy will be given that name. o If the destination is a directory, the new file copy have the same name, and will be in the designated directory. =`To copy the file prog1.java from current directory on the +`A: drive to the current directory on the +`current default drive: +`
D:\student>copy a:prog1.java
y y
item`* =`To copy the file prog1.java from current directory on the +`A: drive to the \student directory on the D drive: +`
C:\winnt>copy a:prog1.java d:\student
item`* =`
y
To copy the all of the files in current directory on the +`A: drive to the \student directory on the D drive: +`
C:\winnt>copy a:*.* d:\student
+`The help will vary, depending on the OS version. +`With Windows NT 5.0 (2000), item`*
Examples
Help - COPY /? Help can be displayed with the command
COPY /?
The help will vary, depending on the DOS version. With Windows NT 5.0 (2000),
Copies one or more files to another location. COPY [/V] [/N] [/Y | /-Y] [/Z] [/A | /B ] source [/A | /B] [+ source [/A | /B] [+ ...]] [destination [/A | /B]] source /A /B destination file(s). /V /N with a /Y an Specifies Indicates Indicates Specifies the file or files to be copied. an ASCII text file. a binary file. the directory and/or filename for the new
Verifies that new files are written correctly. Uses short filename, if available, when copying a file non-8dot3 name. Suppresses prompting to confirm you want to overwrite
/-Y /Z
existing destination file. Causes prompting to confirm you want to overwrite an existing destination file. Copies networked files in restartable mode.
The switch /Y may be preset in the COPYCMD environment variable. This may be overridden with /-Y on the command line. Default is to prompt on overwrites unless COPY command is being executed from within a batch script. To append files, specify a single file for destination, but multiple files for source (using wildcards or file1+file2+file3 format).
DELETE COMMAND
Usage
Files can be deleted by using the DEL or ERASE command.
Command Syntax ERASE options filespec DELETE options filespec Options /P (Prompt) Prompt for confirmation before deleting. (Default for *.*) /Q (Quiet mode) Do not prompt for confirmation. /S (Subdirectories) Delete matching files from subdirectories. /F (Force) Delete files with the read-only attribute /A (Attributes) Delete files with the specified attributes.
y y y y
R S H A
Read-only attribute set System attribute set Hidden attribute set Archive attribute set
y y y y
-R -S -H -A
Read-only attribute cleared System attribute cleared Hidden attribute cleared Archive attribute cleared
Remarks
y y
The ERASE command is the same as the DEL command. The Filespec can be: o A file name (with extension.) The file will be deleted from the current directory. o A file spec with wildcards. All files matching the pattern will be deleted from the current directory. o A pathname including a file name. The designated file will be deleted. o A pathname including a file name with wildcards. All files matching the pattern will be deleted from the designated directory.
o
The help will vary, depending on the DOS version. With Windows NT 5.0 (2000),
Deletes one or more files. DEL [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names ERASE [/P] [/F] [/S] [/Q] [/A[[:]attributes]] names names Specifies a list of one or more files or directories. Wildcards may be used to delete multiple files. If a directory is specified, all files within the directory will be deleted. Prompts for confirmation before deleting each file. Force deleting of read-only files. Delete specified files from all subdirectories. Quiet mode, do not ask if ok to delete on global Selects files to delete based on attributes R Read-only files S System files H Hidden files A Files ready for Prefix meaning not
If Command Extensions are enabled DEL and ERASE change as follows: The display semantics of the /S switch are reversed in that it shows you only the files that are deleted, not the ones it could not find.