Menu
Is free
registration
home  /  Education/ Basic cmd commands - just useful. Removing directories

Basic cmd commands are just about useful. Removing directories

Command RMDIR has a synonym RD and is designed to delete directories of the Windows file system.

Command line format:

RMDIR [drive:] path

RD [drive:] path

Command line parameters:

/ S- Deleting a directory tree, that is, not only the specified directory, but also all the files and subdirectories it contains.

/ Q- Disable confirmation prompt when deleting a directory tree using a key / S.

Examples of using the command RD (RMDIR)

Command RD does not support file and subdirectory name patterns. So, for example, trying to execute the command RD C: \ Users \ *. *, will end with an error message in the directory name. However, several directory paths can be specified as parameters:

RD C: \ Mydocs C: \ Myprogs- delete the contents of the folders C: \ Mydocs and C: \ Myprogs.

RD C: \ docs- delete the folder C: \ docs. If the parameter / S not specified, the folder to be deleted C: \ docs should be empty.

RD / S / Q C: \ Docs- deleting the C: \ Docs folder and all its subfolders without asking for confirmation.

The peculiarity of the implementation of the RD command with a parameter / S is that not only subdirectories will be deleted, but also the C: \ Docs directory itself, even if files and not subfolders existed in it. Therefore, to delete only the contents of the directory (when you want to make the directory empty, and not delete it at all), you can use the following technique - make the directory to be deleted current and run the command RD in relation to its content:

CD "My Folder"

RD / s / q "My Folder"

A directory name containing spaces is enclosed in double quotes. Since the CD command made the directory to be deleted current, its deletion will not be performed, and the key / S will delete all subdirectories and files of the "My Folder" directory

The below batch file deletes empty folders in the temp directory specified by the value of the environment variable TEMP... The list of deleted folders is written to a file named c: \ tempfoldersempty.txt

FOR / D %% i in (*) do (

RMDIR / Q %% ~ i && echo %% ~ i >> c: \ tempfoldersempty.txt

Recommendations will help you completely delete the folder via command line... In the article about, the DEL command was used, which is intended specifically for files. In the case of folders, the RD or RMDIR commands are applicable.

To achieve the goal,. Enter RD /? and take a quick look at the command's features and parameters. Here you will see only 2 parameters:

  1. / s - when using this prefix, the folder will be deleted, as well as all its nested items. If your directory is not empty, and you have not specified this parameter, then nothing will work for you.
  2. / Q - used when deleting without confirmation.

In general, the construction looks like this:

RD or RMDIR / s / q “full folder path”

Note: when applying the design, the directory and its contents will be completely deleted from the computer and you will not find it in the basket. For safety, make a backup copy of the folder.

Deleting a folder with or without confirmation

On my computer, I created a directory called "cmd" and copied several objects into it. Then I entered the following command into the command line:

RD / s “c: \ cmd”

Then I pressed Enter and the Y key, as cmd made a request to confirm the deletion.

After checking the C drive, I did not find a directory. Then I created a folder named "delete" and also copied 5 files, but when I entered the command, I removed the / s prefix. It turned out like this:

RMDIR “c: \ delete”

After pressing Enter, the deletion did not happen, and a message was displayed on the command line that the folder was not empty. Conclusion, without the / s parameter, you can only delete an empty folder, therefore, using it without this prefix is ​​practically useless.

If you are too lazy to enter the confirmation letter (Y or N), then the following construction is for you. The / q prefix was mentioned above, it is he who removes the annoying input of letters (see the screen for proof).

OPERATING SYSTEM MS DOS

Methodical instructions for laboratory work on the course

"Operating systems" for students of the specialty 230401 "Information systems"

Balakovo

purpose of work- Acquisition of basic practical skills when working with the MS-DOS operating system.

Basic concepts

Any operating system (OS) provides the user and application programs with a means of communication (interface) with multiple computer devices. It receives various commands from the user and executes them. Application programs, being launched by the user (again, not without the help of the OS), themselves actively use the services of the OS. For example, if you need to print a text document on a printer, then the text editor, in the window of which this document is located, will not directly interact with the printer itself, but entrust this work to the operating system. That, in turn, will check: whether the printer is on, whether it is working properly, whether its tray is loaded with paper. And only after that it will feed the text for printing in certain portions, constantly observing the state of the operating printer. There is a wide variety of operating systems: MS-DOS, Windows 7, Windows 2003, Linux, Unix and many others. They differ from each other in capabilities, usability, performance and other characteristics.

MS-DOS stands for MicroSoft Disk Operating System, i.e. disk operating system of the American company Microsoft. The term "disk" means that the OS is located on the disk: either on the hard drive, or on

from a floppy disk (MS-DOS sizes allow this), or even on a CD.

The algorithm for choosing a particular device is set in the BIOS. For example, if the A :, C: drives are listed under BIOS FEATURES SETUP under Boot Sequence, this means that if a floppy disk (drive A :) is installed in the computer, an attempt to boot MS-DOS from it, if there is no floppy disk, then MS-DOS will boot from the hard drive (drive C :).

The MS-DOS operating system consists of the following parts:

1) BIOS (Basic Input-Output System). This part of the OS is hardwired into ROM or ROM (Read Only Memory). The BIOS contains tests for checking the nodes of the computer (they are automatically launched when the computer is turned on), as well as the Boot Loader, a small program for calling the more complex MS-DOS Loader (a fragment of the io.sys file). In addition, the BIOS performs low-level I / O operations (at the register level) with the monitor, keyboard, disks, and printer.

2) Disk files io.sys and msdos. sys. The io.sys file (located in the initial sector of the system disk) contains, as mentioned, the MS-DOS Loader program. In addition, io.sys complements the BIOS with other low-level I / O operations. The msdos.sys file provides basic high-level MS-DOS services.

3) File command.com - Command processor or MS-DOS command interpreter. Contains basic MS-DOS commands: CLS, DIR, COPY and others, called internal. In addition, it works with external MS-DOS commands such as FORMAT, DELTREE and others, which are usually located in the DOS directory and are files with the .com or .exe extension. The command.com command processor organizes the execution of any user commands entered from the keyboard or using command files (files with the .bat extension). The MS-DOS components listed above are the minimum components of this operating system. In addition to it, you can specify such MS-DOS elements as:

4) external MS-DOS commands. They are, as mentioned, files with the .com or .exe extension and are usually located in the DOS directory.

5) Drivers. These are special programs (files with the .com,. Exe, or .sys extensions) that provide service to new or non-standard use of existing external devices. The required drivers are activated using the config.sys and autoexec.bat files.

6) The config.sys file. It is a plain text file containing special commands for activating various drivers. In addition, it can be used to change the operating modes or configuration of MS-DOS.

7) The autoexec.bat file. This is a batch file automatically launched by the operating system for execution when the computer is turned on or restarted.

The user's dialogue with DOS is carried out in the form of commands entered in response to the so-called operating system prompt. It is displayed on the display screen and usually looks like this:

current disk name: \ current directory name> _,

where> is a system symbol;

For example, C: \ lab> _,

where C is the name of the current disk;

lab - the name of the current directory

If the current directory is the root, then the name of the current directory is omitted, since it is the same as the name of the current drive. The prompt in this case looks like this:

C: \> _

Entering commands. DOS includes several dozen commands. They are typed on the command line at the DOS prompt. The syntax or general format for a command is as follows:

command name [arguments],

where arguments are objects that the command operates on;

parameters are identifiers of the command execution modes (they are separated by a slash "/").

To display the arguments and parameters of a command, run the command help command name

To execute any command, press the Enter key (no further indication of pressing the Enter key will be indicated).

The main DOS commands are conventionally divided into four groups.

1. Commands of general purpose.

2. Commands for working with disks.

3. Commands for working with directories.

4. Commands for working with files.

Disk management commands are not used in this lab, so they are not covered further.

MS-DOS has standard file type conventions that allow you to visually define the nature of files.

COM - command file;

EXE - executable file;

BAT - batch file;

SYS - system file;

TXT - text file

General purpose commands.

The most commonly used commands in this group are:

1) cls (Clear Screen) - clear the screen;

2) ver– output of the version of the operating system installed on the computer;

3) date– display and set the current date;

4) time - display and setting of the current time;

5) help– display of help data on DOS commands;

You can use the following keys to call previously entered commands into the command line and manage the list of commands:

- calling the previous command;

↓ - call the next command;

F7– display of a list of previously entered commands;

F9– copying to the command line one of the commands of the displayed list (F7) by selecting its number;

Alt + F7– clear the command list.

Directory Commands

Command DIR- directory - directory (directories) - is used to display a list of files and subdirectories located in the specified directory.

For example, C: \> dir - view the root directory of the C drive.

C: \> dir lab - view the contents of the lab directory.

If the specified directory contains a large number of subdirectories and files, then you can organize their page-by-page output using the / P switch. In this case, after displaying one page of the list, DOS will wait for any key press to continue displaying the next pages. For example, dir c: \ windows / p

!! Browse the contents of the root directory of the C: drive using page-by-page browsing.

Command TREE- displaying the directory tree on the screen.

Command format: TREE[drive] [path] [name] [| more]

where disk is the name of the disk that hosts the directory system;

path - the path to the directory whose tree you want to view;

name - the name of this directory;

/ f - the mode of displaying the directory tree with the files they contain;

| more - command for pipelining output in portions of 23 lines.

For example, C: /> tree C: / f | more

!! Display the directory tree of the C: drive in portions of 23 lines without files.

Command MD- Make Directory - create directories and subdirectories.

Command format: MD [drive] [path] name

where disk is the name of the disk on which the directory is created;

path - the path to the created directory from the root or current directory;

name - the name of the directory to be created.

For example, C: /> md lab

!! Create an X directory on the C: drive.

Command CD- Change Directory - change the current directory.

Command format: CD [path] name

where path is the path to a subdirectory in the hierarchical file structure;

name - the name of the subdirectory to be declared current.

For example, cd C: \ Windows

To return to the root directory from the current subdirectory of any level, you must enter the command cd \

If you need to move up one level, you must enter the command cd ..

Here (..) stands for parent directory.

!! Change to directory X. Notice the changes at the DOS prompt.

!! Create two subdirectories Y and Z in the current directory.

Change the current disc. To change the current disk, you need to type the name of the drive, which should become the current one. After executing this command, a DOS prompt will appear with the current drive.

Copying directories. To copy one directory to another, use the command XCOPY... This command makes it possible to copy a directory with a change in its name.

Command format:

where
where
XCOPY [drive] [path] old_name [drive] [path] old (new) name

where / s - copy mode of non-empty directories (together with files and subdirectories);

/ e - mode for copying empty directories.

For example, we copy directory 1 to directory 2 under the name 3

xcopy d: \ x \ 1 d \ x \ 2 \ 3 / s / e (do not type - this is an example)

!! Copy directory Z to directory Y under the name Q. Check the result with the TREE command.

Moving directories... To move directories, use the command MOVE.

Command format:

MOVE [drive] [path] old_name [drive] [path] [new_name]

When transferring a directory to the current directory, it is necessary to specify either the new (old) name of the transferred directory or the full path to the current directory in the "where" part of the address.

For example, see the command is similar to the example above

!! Change to the root directory, then move the Q directory to the X directory. Verify the result by displaying the X directory tree.

Renaming directories. The directory name is changed using the command REN.

Command format: REN [drive] [path] name1 name2

where name1 is the old directory name;

name2– the new name of the directory.

!! Name X directory W. Verify command execution.

Removing directories. Removing directories is done using the RD command.

Command format: RD[drive] [path] name

where disk is the name of the disk where the directory to be deleted is located;

path - the path to the directory to be deleted;

name - the name of the directory to be deleted.

You can delete a directory only from outside the directory. The root directory cannot be deleted. After pressing Enter, the operating system will prompt: Delete directory "[drive] [path] name" along with all subdirectories? ... To delete, you must press Y (yes) and Enter, to cancel - N (no) and Enter.

!! Delete directory Y. Verify the execution of the delete command using the TREE command.

File Commands

DEL command

DEL attributes]] names

ERASE attributes]] names

Names The names of one or more files. Wildcards are used to delete multiple files at once.

If a directory is specified, all files will be removed from it.

/ P Prompt for confirmation before deleting each file.

/ F Force the deletion of read-only files.

/ S Removes the specified files from all subdirectories.

/ Q Disable the confirmation prompt when deleting files.

/ A Select files for deletion by attributes.

Attributes S System files R Read-only

H Hidden files A Files for archiving

The prefix "-" is NOT

Changes to DEL and ERASE commands when extended command processing is enabled:

The output for the / S switch is reversed, that is, only the names of deleted files are displayed, not files that could not be found.

Example: 1. Deleting all files with extension .txt

A: Jobs> del * .txt

A: Quests>

2. Deleting files starting with the letter "T"

A: Jobs> del T * .txt

A: Quests>

RMDIR / Q / R / S] [@file] path ...

pathThe name of one or more subdirectories to remove.
@fileA text file containing the names of the directories to remove, one per line (see@file lists for details).

File Completion Syntax:

RD sets two internal variables:

% _rd_dirsThe number of directories deleted
% _rd_errorsThe number of errors

(Note that if you do an RD / S, the actual deletions are done by DEL, so check the DEL variables.)

Options:

/ I "text"Select directories by matching text in their descriptions. The text can include wildcards and extended wildcards. The search text must be enclosed in double quotes, and must follow the/ I immediately, with no intervening spaces. You can select all filenames that have a description with/ I "[?] *" , or all filenames that do not have a description with/ I "" ... Do not use / I with @file lists. See @file lists for details.
/ KWhen used with the / S option, this will physically delete files instead of sending them to the Windows Recycle Bin, even if you have the Delete to Recycle Bin configuration option set.