Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the DOS commands commonly used in batch processing

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

What are the commonly used DOS commands in batch processing? for this problem, this article introduces the corresponding analysis and solutions in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

one。 Create a folder: md

The md command is used to create a folder, the path in the following example can be defaulted, if the default is to create a new folder under the current directory; if the new folder and its path with spaces or special symbols, to enclose in double quotation marks.

1. Create a single folder

Format: MD [path\] directory

Example 1

Md d:\ abc

Create a folder called abc under disk D.

Example 2

Md abc

If this is the default path, create a folder called abc under the current directory.

Example 3

Md "d:\ my game"

Create a folder called my game under disk D.

For newly created folder names that contain spaces or special symbols, be sure to enclose the folder name in double quotes.

Example 4

Md "C:\ Documents and Settings\ 456 ^ 789"

Create a folder called 456^ 789 under C:\ Documents and Settings. Because there are spaces in the path, we enclose the path and the folder name in double quotes.

two。 Create multiple directories at the same time

Format: md [path\] directory 1 [path\] directory 2 [path\] directory 3.

Example 5

Md abc D:\ gmae\ 123 abcd

Create two files, abc and abcd, in the current directory, and create a folder 123 under D:\ gmae.

3. Create a multi-level directory

Format: md [path\] directory 1\ directory 2\ directory 3\...

If we want to create a folder abc under disk D, then create a new folder abcd in abc, and then create a folder abcde in abcd, is there a command that can be done at once? The answer is yes!

Example 6

Md d:\ abc\ abcd\ abcde

It's just one order, don't you believe it? Of course you can test it, hehe.

Think about:

In example 4, what happens if the command is not enclosed in double quotes, that is, md C:\ Documents and Settings\ 456 ^ 789? This is for everyone to test, !

two。 Delete folder: rd

Delete a directory.

RMDIR [/ S] [/ Q] [drive:] path

RD [/ S] [/ Q] [drive:] path

/ S in addition to the directory itself, all subdirectories under the specified directory and

Files. Used to delete the directory tree.

/ Q quiet mode, no confirmation is required when deleting the directory tree with / S

The rd command can only delete empty folders without any parameters.

Example 1.

Rd d:\ 123

Rd abc

The first is to delete the empty folder 123 under disk D. The second is to delete the empty folder abc under the current directory.

In addition to the directory itself, / S deletes all subdirectories and files under the specified directory. Used to delete the directory tree.

Example 2.

Rd / s d:\ 123

If the folder 123 is not empty, the folder 123 can be deleted through the / S parameter.

/ Q quiet mode, no confirmation is required when deleting the directory tree with / S.

Example 3.

Rd / s / QD:\ 123

When using the / S parameter, the system will prompt: d:\ 123 whether to confirm (YUnip N)? At this point, the / Q parameter can be used to delete it without being asked.

three。 Rename files (folders): ren

Rename the file.

RENAME [drive:] [path] filename1 filename2.

REN [drive:] [path] filename1 filename2.

The path to filename1 can be omitted and is the current directory by default. Filename2 can only be a file name and cannot use any path.

1. Renaming of a single file

Example 1

Ren d:\ 123.txt 456.bat

Rename 123.txt to 456 and change the suffix to bat.

Example 2

Ren 123.txt 456.bat

By default, rename the 123.txt in the current directory to 456.bat.

two。 Batch renaming

Through * and? These two wildcards are used for batch renaming. * represents any number of characters,? Represents a character.

Example 3

Ren * .bat * .txt

Change the file with the suffix name bat in batch to the file after the txt suffix.

★ for wildcards? It's more complicated, so I won't talk about it here. Please find more information about it.

★ when the file has hidden attributes or system attributes, ren can not be renamed directly, you need to remove the hidden or system attributes of the file before renaming, which we should pay attention to!

four。 Move files (folders): move

Move files and rename files and directories.

To move at least one file:

MOVE [/ Y | /-Y] [drive:] [path] filename1 [,...] Destination

To rename a directory:

MOVE [/ Y | /-Y] [drive:] [path] dirname1 dirname2

[drive:] [path] filename1 specifies the location and name of the file you want to move.

Destination specifies the new location of the file. The destination can contain a drive letter

And a colon, a directory name, or combination. If you move only one file

And rename it as you move, and you can include the file name.

[drive:] [path] dirname1 specifies the directory to rename.

Dirname2 specifies the new name of the directory.

/ Y unconfirm the prompt to overwrite an existing target file.

/-Y sends a prompt to confirm that an existing target file is overwritten.

1. Move files (folders)

Basic format: MOVE [/ Y | /-Y] [drive:] [path] filename1 [,...] Destination

[drive:] [path] filename1 [,...]

Files (folders) you want to move can use either a relative path or an absolute path, which is the current directory by default.

Destination can only be a directory path, you can use a relative path or an absolute path, which defaults to the current directory by default.

Example 1

Move d:\ abcd:\ abcd

If you move the folder abc to the folder abcd.

Example 2

Move 123.txt abc

Move the 123.txt under the current directory to the current folder abc. Relative paths are used here, which defaults to the current directory by default.

Example 3

Move 123.txt e:\ abc

Move the 123.txt in the current directory to the e:\ abc directory.

two。 Rename files (folders)

Example 4

Move d:\ abcd:\ abcd

Note here that if the destination folder abcd does not exist, move abc to d:\ and change its name to abcd.

Taking advantage of this feature, the move command has renaming capabilities.

Example 5

Move d:\ 123.txt d:\ abc\ 456.txt

If 456.txt exists, you will be prompted to rewrite D:\ 456.txt? (Yes/No/All):

When you type Y, 123.txt will overwrite 456.txt. If 456.txt does not exist, move 123.txt to the d:\ abc directory and rename it to 456.txt.

Example 6

Move / y 123.txt 456.txt

If both 123.txt and 456.txt exist, after passing the / y parameter, the system will not prompt you, but will directly overwrite the 123.txt with 456.txt.

Example 7

Move 123.txt e:\ abc\ 456.txt

For cross-zone movement, if 456.txt exists, it will prompt that the file exists. The command will not be executed; if 456.txt does not exist, move 123.txt to the e:\ abc directory and rename it to 456.txt.

The ★ MOVE command can move files across partitions, but not folders.

★ for moving files across partitions, if the target location exists with the same name as the file to be moved, the system will prompt: "File exists." finally, the command will not be executed.

★ for files with hidden or system attributes, the move command will not be executed until their attributes are removed.

Let's sum it up:

For a pattern like move A B

1. If An and B are both folder names

① if B exists, move A to the B directory. (example 1)

② if B does not exist, move A to the same directory as B and rename it to B. (example 4).

2. If An is the file name and B is the folder name

① will move A to the B directory. (example 2, example 3)

② if there is a file with the same name as file An in folder B:

If I An and B are the same partition, then prompt: do you want to overwrite / not overwrite / overwrite all?

If II An and B are different partitions, you are prompted that the file exists. Don't do anything!

3. If An and B are both file names

① An and B are the same partition, if B exists, you will be prompted whether to rename A to B; if B does not exist, move A to the same directory as B and rename it to B. (example 5)

② An and B are different partitions, and if B exists, the command is not executed; if B does not exist, move A to the same directory as B and rename it B. (example 7).

The answers to the questions about the commonly used batch processing DOS commands are shared here. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel for more related knowledge.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report