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-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Batch processing commonly used DOS commands are what, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

1. Set file attributes: attrib

Displays or changes file properties.

ATTRIB [R |-R] [A |-A] [S |-S] [H |-H] [[drive:] [path] filename] [/ S [/ D]]

Set the properties.

-clear the attribute.

R read-only file properties.

An Archive file properties.

S system file properties.

H hides file properties.

[drive:] [path] [filename] specifies the file attributes to be processed.

/ S processes matching files in the current folder and its subfolders.

/ D also handles folders.

one. View the file properties of a file

Format: ATTRIB [drive:] [path] [filename]

Example 1

Attrib d:\ pagefile.sys

View the properties of the d:\ pagefile.sys file.

two. Modify the properties of the file.

Format: attrib? Attribute

Example 1

Attrib-h d:\ pagefile.sys

Remove the "hidden" attribute of d:\ pagefile.sys.

Example 2

Attrib s h d:\ pagefile.sys

Set the system and hide properties for d:\ pagefile.sys.

three. Batch file processing

Example 1

Attrib h d:\ 123\ * .bat / s

The / s parameter allows you to batch set all bat files in d:\ 123 and its subdirectories to the Hidden attribute.

Example 2

Attrib h d:\ 123 / s / d

Set d:\ 123 and all subdirectories with the same name 123 to the hide attribute. The parameter / d must set the file properties in batches while setting the specified directory and

All subdirectories under it perform file attribute operations. The parameter / d can be understood as "directory" (directory), which means / d must be used with / s.

Think about:

What's the difference between "attrib h d:\ 123 / s / d" and "attrib h d:\ 123\ *. * / s / d"?

In the former, only d:\ 123 and its subdirectories with the same name are set to "hidden", while other files and subdirectories are not set to "hide".

The latter sets the "hide" attribute for all files and subdirectories under d:\ 123, but the d:\ 123 directory does not set the "hide" attribute.

Delete command: del

Delete one or more files.

DEL [/ P] [/ F] [/ S] [/ Q] [/ A [[:] attributes]] names

ERASE [/ P] [/ F] [/ S] [/ Q] [/ A [[:] attributes]] names

Names specifies one or more file or directory lists. Wildcards can be used to

Delete multiple files. If you specify a directory, the places in the directory

All files will be deleted.

/ P prompt for confirmation before deleting each file.

/ F forcibly delete read-only files.

/ S removes the specified file from all subdirectories.

/ Q quiet mode. No confirmation is required when you delete a global wildcard.

/ A selects the file to delete based on the attribute.

Attributes R read-only files S system files

H hide file An archive file

-prefix for "No"

Basic format: DEL [drive:] [path] [filename]

Example 1

Del d:\ 123\ abc.txt

Delete abc.txt

/ P prompt for confirmation before deleting each file.

Example 2

Del / p d:\ 123\ *. *

Delete all the files in the d:\ 123 directory. If you want it to ask you if you want to delete it before deleting it, we can add the / p parameter to prevent accidental deletion.

/ S removes the specified file from all subdirectories.

Example 3

Del / s d:\ 123\ *. *

Delete all files under the d:\ 123 directory and its subdirectories.

By using the / s parameter, the del command searches for all files with the specified filename in the specified directory (or the current directory if not specified) and its subdirectories and deletes them

Except.

/ Q quiet mode. No confirmation is required when you delete a global wildcard.

Example 4

Del / s / QD:\ 123\ *.

Delete all files under the d:\ 123 directory and its subdirectories.

Delete directly without confirmation through the / Q parameter, be careful when using this parameter!

/ A selects the file to delete based on the attribute.

Example 5

Del / ar / s d:\ 123\ *. *

Delete all files with read-only attributes under the d:\ 123 directory and its subdirectories.

Here we choose to delete the file with the specified attribute through the / a:attributes parameter. File attribute attributes, optional r (read-only), s (system)

, h (hidden), a (archiving).

3. Copy the file: copy

Copy can only copy files, not folders.

one. Copy of a single file

Format: copy source [drive:] [path] [filename] [destination [drive:] [path] [filename]]

That is, the destination path [\ file name] of the source file (including path and file name) to be copied by copy, when [destination [drive:] [path]

[filename]] the default is the current directory.

Example 1

Copy c:\ 123.txt d:\

Copy 123.txt to the d:\ directory. If this operation is successful, the command line window prompts "1 file copied".

Example 2

Copy c:\ 123.txt d:\ abc.bat

Copy 123.txt to the d:\ directory and change it to abc.bat, where the file name and its format are changed.

Example 3

Copy.

Copy all the files in the 123 subdirectory under the current directory to the current directory. It seems a little difficult to understand here, hehe, explain: for example, the current directory is

C:\ windows, it has many subdirectories, now copy all the files in one of its subdirectories to the current directory c:\ windows, so it should be clear

It's white! ~

two. Copy files in bulk

Example 1

Copy c:\ 123d:\ abc

Copy all the files in the c:\ 123 directory to the d:\ abc directory.

Example 2

Copy c:\ 123\ * .rm d:\ abc / y

Copy all the files in rm format in the c:\ 123 directory to the d:\ abc directory, when the same text already exists in the destination directory as the files to be copied in the source directory

When a file is named, a prompt such as "rewrite x:\ xx? (Yes/No/All):" will appear, giving you a choice of whether to overwrite, not overwrite, or overwrite all of them.

With the parameter / y, which can be used to copy a single file or a batch copy, you can overwrite a file with a duplicate name without confirmation.

three. Merge Fil

Format: copy / b file 1 + file 2 +. File N merged file name

Example 1

Copy / b d:\ 1.mp3 d:\ 2.mp3 e:\ 3.mp3

Merge 1.mp3 and 2.mp3 into 3.mp3.

Example 2

Copy / b d:\ 1.txt d:\ 2.mp3

Merge 1.txt and 2.mp3. The combined file name is not specified here. By default, the merged file name is the name of the first file in the command.

In this case, 2.mp3 is merged into 1.txt.

★ hides the picture file of text data at the end, and after editing and saving it with other software, the hidden text data may be lost.

★ MP3 files can be played continuously after being connected using this method.

Binary files such as ★ merge pictures / songs must use the / b parameter (b stands for Binary, binary), otherwise the merge will fail; another merge parameter is / a

(a stands for ASCII, text file) and can only be used for plain text merging. Two parameters cannot be used at the same time, and text and binary files can be merged in binary mode.

The text method can only merge the text.

4. Copy files (folders): xcopy

Copy files and directory trees.

XCOPY source [destination] [/ A | / M] [/ D [: date]] [/ P] [/ S [/ E]] [/ V] [/ W]

[/ C] [/ I] [/ Q] [/ F] [/ L] [/ G] [/ H] [/ R] [/ T] [/ U]

[/ K] [/ N] [/ O] [/ X] [/ Y] [/-Y] [/ Z]

[/ EXCLUDE:file1 [file2] [file3]...]

Source

Necessary. Specify the location and name of the file to copy. The parameter must contain a drive or path.

Destination

Can be omitted. Specify the destination of the file to copy. This parameter can contain drive letters and colons, directory names, file names, or a combination of them.

If you omit the Destination,xcopy command, copy the file to the current directory.

There are too many parameters available for xcopy, so here are only a few commonly used ones to talk about.

/ S copies directories and subdirectories that are not empty. If / sforce xcopy is omitted, it will work in a directory.

Example 1

Xcopy / s d:\ 123e:\ kkk\

Copy all files (folders) under the d:\ 123 directory to e:\ kkk, excluding empty subdirectories. (by default, xcopy does not copy hidden or system files)

/ E copies all subdirectories, including empty directories. Use both the / e, / s, and / t command line options.

Example 2

Xcopy / e d:\ 123e:\ kkk\

Copy all files (folders) under the d:\ 123 directory to e:\ kkk, including empty subdirectories. (by default, xcopy does not copy hidden or system files)

/ H copies files with hidden and system file attributes. By default, xcopy does not copy hidden or system files.

Example 3

Xcopy / e / h d:\ 123e:\ kkk\

Copy all files (folders) under the d:\ 123 directory to e:\ kkk, including empty subdirectories. With the / h parameter added, xcopy copies hidden or system files

/ T only replicates the subdirectory structure (that is, the directory tree), not files. To copy an empty directory, you must include the / e option.

/ Y disables prompting you to confirm that you want to overwrite the existing target file.

When the same file name already exists in the destination directory as the file to be copied in the source directory, "rewrite X:\ XXX (Yes/No/All)?" appears.

Such a prompt allows you to choose whether to overwrite, not overwrite or all overwrite, through the parameter / y, you can directly overwrite the duplicate file without confirmation.

★ notes that you specify whether Destination is a file or a directory.

If the Destination does not contain an existing directory and does not end with a backslash (\), the following message appears:

Does destination specify a file name

Or directory name on the target

(F = file, D = directory)?

The system will ask you

Is destination X:\ XXX a file name or a directory name?

(F = file, D = directory)?

If you want to copy one or more files to a file, press F. If you want to copy one or more files to a directory, press D.

Think about:

What is the difference between xcopy / e d:\ 123e:\ kkk\ and xcopy / e d:\ 123e:\ kkk?

Both copy all files (folders) under the d:\ 123 directory to e:\ kkk, including empty subdirectories, but the former will not ask you

Is the destination e:\ kkk a file name or a directory name

(F = file, D = directory)?

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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