Batch processing often used by the BAT recommended under _dos/bat

Source: Internet
Author: User
C-Disk conversion to NTFS-formatted batch
Copy Code code as follows:

@ ECHO off
@ ECHO.
@ ECHO. Description
@ ECHO---------------------------------------------------------------
The @ ECHO NTFS format is the WinXP recommended format. converting to NTFS can improve the storage of your hard disk
@ ECHO efficiency, and you can set access permissions to protect files. But NTFS-formatted partitions are in Dos/win9x
@ ECHO can not be recognized, may cause inconvenience to novice users. Do not convert if you need not.
@ ECHO---------------------------------------------------------------
@ ECHO.
Convert C:/fs:ntfs

Several dangerous orders in batch processing
1, Format disk Formatting command
Because the format command formats the disks that are already in use, you can delete all the files on the disk, so before using this command, you should use the dir command to check whether the contents of the disk need to be retained. Also note that you should prevent the disk from being incorrectly formatted due to errors in the command entry.
2. diskcopy Disk Copy command
When this command is copied, the destination disk is reformatted in the same format as the source disk, regardless of whether the destination disk has the information stored. Therefore, the use of this command, on the one hand should be checked on the destination disk, there are no useful files, on the other hand should prevent the source and destination disk error, but the source disk format. The source disk should be write-protected before copying.
3. Backup Backup-to-disk command
Before using this command, if you do not use the parameter/A, the original file on the destination disk will be deleted. Therefore, you should check that the contents of the destination disk are useful before backing up, or use parameter/a for backup.
4, del Delete file command
Since this command allows you to delete a batch of files by using the wildcard character * and?, it is recommended that you use the dir command to see if the deleted file is correct before using this command to avoid accidentally deleting a large number of files. Then execute this command again.
5. copy file copying command
Because the copy command overwrites the file with the same name as the original on the destination, you should ensure that it does not have the same name as the original file on the destination disk when you name the destination file name.
To add MS-DOS to the right
Some of the tools are command-line-mode (CLI), and each time you go from run to CMD, it's cumbersome to get into the folder where the tool is located. Let me tell you a simple way to make Windows accessible to the CLI at any time, just like Linux.

Open Registry Editor, find HKEY_CLASSES_ROOT\Directory\shell, then select it, click the right mouse button, create a new primary key, name "DOS", then select the new primary key, double-click the default string value on the right, and in the pop-up dialog box, type " Go to Dos window, and then select the new primary key, then create a primary key, named "command", select the "command" primary key, modify the default value of "cmd.exe/k" CD%l "".

Note: "CD%l" is entered into the current folder.

In the task Manager to end the Explorer.exe, and then run the Explorer.exe on it, the setting is effective. No reboot is required.

Now casually right key to a folder, to see if there is a key in the "Go To Dos window"? So you can open MS-DOS anytime and anywhere, not as troublesome as it used to be.

Shift the use of this batch command

In DOS batches, only%1-%9 9 command-line arguments are supported (% 0 is used to indicate the command itself). If you want your batch to support more than 9 command-line arguments, you need to use the shift command, and once the shift command is run, the command line arguments move left one bit, that is,%2 becomes%1,% 3 becomes% 2, ..., and so on. As a simple example, you build a batch, assuming the name Tstshift.bat, which reads:
@echo off
Echo%0
Echo%1%2%3%5%6%7%8%9
Echo%1
:: 1
Shift
Echo%1
:: 2
Shift
Echo%1
:: 3
Shift
Echo%1
:: 4
Shift
Echo%1
:: 5
Shift
Echo%1
:: 6
Shift
Echo%1
:: 7
Shift
Echo%1
:: 8
Shift
Echo%1
:: 9
Shift
Echo%1
:: 10
Shift
Echo%1
And then run:
Tstshift 0 1 2 3 4 5 6 7 8 A run the results are as follows:
D:\>tstshift 0 1 2 3 4 5 6 7 8 9 A
Tstshift
0 1 2 3 4 5 6 7 8
0
1
2
3
4
5
6
7
8
9
A above is the function supported by all SHIFT commands, and the shift function under 2000/xp/2003 adds a/n parameter that specifies the shift from the nth parameter. The Chinese help for the shift command under 2000/XP/2003 is:
D:\>shift/?
Change the location of replaceable parameters in a batch file. Shift [/n] If the command extension is enabled, the SHIFT command supports the/n command-line switch; the command line switch tells
The command shifts from the nth argument; n is between 0 and eight. For example: SHIFT/2 will shift%3 to%2, shift% 4 to%3, and so on, and will not affect%0 and%1.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.