SoFunction
Updated on 2025-04-08

Recommended bat for batch processing

Batch processing for converting C disk to NTFS format
Copy the codeThe code is as follows:

@ ECHO OFF 
@ ECHO. 
@ECHO.                                                             �
@ ECHO --------------------------------------------------------------- 
@ ECHO NTFS format is a format recommended for WinXP. Converting to NTFS format can improve hard disk storage
@ ECHO Efficiency and can set access rights to protect files. But the partition in NTFS format is in DOS/WIN9X
@ ECHO cannot be identified, which may cause inconvenience to beginners. If it is not necessary, please do not convert.
@ ECHO --------------------------------------------------------------- 
@ ECHO. 
convert c:/fs:ntfs 

Several dangerous commands in batch processing
1. FORMAT disk formatting command
Since the FORMAT command can format the used disk, thus deleting all files on the disk, before using this command, you should first use the DIR command to check whether the content on the disk needs to be retained. In addition, attention should be paid to prevent errors in formatting the disk due to errors in command input.
2. DISKCOPY disk copy command
When copying this command, regardless of whether the destination disk has stored information, the destination disk will be reformatted to the same format as the source disk. Therefore, when using this command, on the one hand, you should check whether there are useful files on the destination disk, and on the other hand, you should prevent the source disk and destination disk from being misproduced and format the source disk. The source disk can be written to the write-protected before copying.
3. BACKUP disk backup command
Before using this command, if parameter /A is not used, the original file on the destination disk will be deleted. Therefore, before backing up, you should check whether the contents of the target disk are useful, or use parameter /A for backup.
4. DEL file deletion command
Since this command can use wildcard characters * and ? to delete a batch of files, in order to avoid accidentally deleting a large number of files, it is recommended to use the DIR command to check whether the deleted files are correct before using this command. Then execute this command.
5. COPY file copy command
Since the COPY command will overwrite the original file with the same name on the destination disk when copying a file, when naming the file name, it should be ensured that it does not have the same name as the original file with the destination disk.
Add ms-dos to the right-click
Some tools are in command line mode (CLI). Every time you enter cmd from running, isn't it very troublesome to enter the folder where the tool is located? Let me tell you a simple method, so that Windows can enter the CLI anytime, anytime, like Linux.

Open the Registry Editor, find HKEY_CLASSES_ROOT\Directory\shell, then select it, right-click, create a new primary key, name it "DOS", then select the newly created primary key, double-click the default string value on the right, enter "Go to DOS Window" in the pop-up dialog box, then select the newly created primary key, then create a primary key, name it "command", select the "command" primary key, and modify the default value to " /k "cd %L"".

Note: "cd %L" is to enter the current folder.

End it in the task manager and run it again, and the settings will take effect. No restart is required.

Now right-click a folder and see if there is a "Go to DOS window" in the key? This way you can open ms-dos anytime and anywhere, not as troublesome as before.

How to use shift batch command

In DOS batch processing, only 9 command line parameters %1 - %9 are supported (%0 is used to represent the command itself). If you want your batch to support more than 9 command line parameters, you need to use the shift command. Every time you run the shift command, the command line parameters will be shifted left by one, that is, %2 becomes %1, %3 becomes %2,..., and so on. For a simple example, you create a batch, assuming the name is as follows:
@echo off
echo %0
echo %1 %2 %3 %4 %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
Then run:
tsshift 0 1 2 3 4 5 6 7 8 9 a run result is 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
aThe above is a function supported by all shift commands, and the shift function under 2000/xp/2003 has added a /n parameter to specify the shift starting from the nth parameter. The Chinese help of the shift command under 2000/xp/2003 is:
D:\>shift /?
Change the location of replaceable parameters in the batch file. SHIFT [/n] If the command extension is enabled, the SHIFT command supports the /n command line switch; this command line switch tells you
The command starts shifting from the nth parameter; n is between zero and eight. For example: SHIFT /2 will shift %3 to %2, shift %4 to %3, etc.; and will not affect %0 and %1.