1. Modify the cmd form size
Mode con cols=70 lines=30
2. Modify the color of the form
color [FB]
F is the foreground color, that is, the font color
b is the background color, that is, the cmd window background color
Background list of colors and values:
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
Black |
Blue |
Green |
Lake Blue |
Red |
Purple |
Yellow |
White |
Grey |
Light Blue |
Light Green |
Shallow Green |
Light Red |
Light Purple |
Light Yellow |
Bright White |
3. Print: Echo Something
echo off not print Run command, direct Print command run results, for the line under it is useful.
echo on--Prints the command to be run before printing the command to run the result, which is useful for the rows below it.
@ echo HelloWorld: Do not print this command, directly print the command to run the results, and only useful to the bank.
4. Set Variable: Set Val=value
The calling variable is%val%.
5. New folder: MkDir newfoldername
6. Delete folder: rd/s/q
/s: In addition to the directory itself being deleted, all subdirectories and files under the specified directory are deleted, which is used to delete the directory tree.
/Q: Quiet mode, with/s delete directory tree without requiring confirmation, delete directly.
7. For loop:
@for/L%%i in (1,1,3) do (
echo the value of I is:%%i
)
For loop details refer to: http://blog.csdn.net/pigchan/article/details/5066098
8. Find: Search command
Find "I/activitymanager" Log.txt|find "Displayed com.qiyi.video/. Welcomeactivity ">> ActivityManager.log
Find detailed commands can be consulted: http://www.jb51.net/article/18987.htm
9. Write files
echo HelloWorld > Test.txt new Test.txt and writes to Hellowworld, overwriting writes if Test.txt already exists.
echo HelloWorld >> test.txt new Test.txt and writes to Hellowworld, append if test.txt already exists.
BAT Common Commands