SoFunction
Updated on 2025-04-06

Detailed explanation of CMD commands Directory class commands (md, cd, rd, dir, path, tree, deltree)

(I) MD - Create a subdirectory

1. Function: Create a new subdirectory
2. Type: Internal command
3. Format: MD[Disk Letter:][Path Name]<Subdirectory Name>
4. Instructions for use:
(1) "Disk Letter": Specify the disk drive letters to create a subdirectory. If omitted, it is the current drive;
(2) "Path Name": The name of the superior directory of the subdirectory to be created. If default, it will be built in the current directory.
Example: (1) Create a subdirectory named FOX in the root directory of disk C; (2) Create a USER subdirectory under the FOX subdirectory.
C: , > MD FOX (create subdirectory FOX under the current drive C drive)
C: , > MD FOX, USER (create the USER subdirectory under the FOX subdirectory)

(II) CD-change the current directory

1. Function: Display the current directory
2. Type: Internal command
3. Format: CD[Disk letter:][Pathname][Subdirectory name]
4. Instructions for use:
(1) If the path and subdirectory name are omitted, the current directory will be displayed;
(2) If the format of "CD," is used, return to the root directory;
(3) If the format of "CD." is used, it will be returned to the previous directory.
Example: (1) Enter the USER subdirectory; (2) Return to the subdirectory from the USER subdirectory; (3) Return to the root directory.
C:, >CD FOX, USER (enter the USER subdirectory under the FOX subdirectory)
C:, FOX, USER>CD. (Return to the previous root directory)
C:, FOX>CD, (Return to the root directory)
C:、>

(III) RD——Delete subdirectory command

1. Function: Delete the directory from the specified disk.
2. Type: Internal command
3. Format: RD [Disk Letter:] [Path Name] [Subdirectory Name]
4. Instructions for use:
(1) The subdirectory must be empty before deleting, that is, you need to enter the subdirectory first, use DEL (delete file command) to delete the files under its subdirectory, and then return to the upper
First-level directory, use the RD command to delete the directory itself;
(2) The root directory and the current directory cannot be deleted.
Example: It is required to delete the USER subdirectory under the FOX subdirectory of the C disk. The operation is as follows:
Step 1: First delete the files in the USER subdirectory;
C、>DEL C:、FOX、USER、*。*
The second step is to delete the USER subdirectory.
C、>RD C:、FOX、USER

(IV) DIR——Show disk directory command

1. Function: Display the contents of the disk directory.
2. Type: Internal command
3. Format: DIR [Disk Letter] [Path] [/W]
4. Instructions for use: /P; When there are too many directories to view, the screen will continue to roll up after being displayed on one screen, which is not easy to see clearly. After adding the /P parameters, the screen will display 23 lines of file information at a time, then pause and prompt; Press any key to continue
Use of /W: Add /W only displays the file name, and the file size and date and time of creation will be omitted. After adding parameters, five file names can be displayed per line.

(V) PATH—path setting command

1. Function: The search path of the device executable file is valid only for files.
2. Type: Internal command
3. Format: PATH [Drive Letter 1] Directory [Path Name 1]{[;Drive Letter 2:], <Drive Way Name 2>…}
4. Instructions for use:
(1) When running an executable file, DOS will first search for the file in the current directory, and if it is found, run it; if the file cannot be found, search the file in the directory one by one according to the path set by the PATH command;
(2) If there are more than two paths in the PATH command, each path is separated by a semicolon ";";
(3) There are three ways to use the PATH command:
PATH[Disk Letter 1:][Path1][Disk Letter 2:][Path2]… (Set the search path of the executable file)
PATH: (Cancel all paths)
PATH: (Show the currently set path)

(VI) TREE——The command to display disk directory structure

1. Function: Displays all directory paths on the specified drive and all file names under these directories.
2. Type: External command
3. Format: TREE[Disk Letter:][/F][》PRN]
4. Instructions for use:
(1) When using the /F parameter, display all directories and all files under the directory. When omitted, only directories are displayed, and no files under the directory are displayed;
(2) When selecting the >PRN parameter, print out the file names in the listed directory and the directory.

(VII) DELTREE——Delete the entire directory command

1. Function: Delete the entire directory and its subordinate subdirectories and files.
2. Type: External command
3. Format: DELTREE [Disk letter:]〈Path name〉
4. Instructions for use: This command can delete all files, subdirectories, and subdirectories below the directory in one step, regardless of whether the file's attributes are hidden, system or read-only.
As long as the file is located in the deleted directory, DELTREE will be treated equally and will be deleted without error. Be careful when using