1. Overview
Copy content: Right-click popup shortcut menu, select "Mark (K)", then select the desired content, then right-click
Paste content: Right-click popup shortcut menu, select "Paste (P)"
Path to the command parameter: To use a backslash ', do not use a forward slash '/' such as Del D:\test2/file\my.txt
Path to the command parameter: if there are spaces, use double quotation marks to enclose the path as del "D:\Program File\my.txt"
The file and directory name cannot contain any of the following characters:/: *? "< > |
REM//Comments are added to the batch file, and subsequent commands will not be executed, but will Echo
:://:: Can also play the role of REM annotation, and there will be no echo
Any word lines that begins with a colon: is treated as a tag (label) in a batch, ignoring everything that follows it directly
有效标号:冒号后紧跟一个以字母数字开头的字符串,goto语句可以是识别无效标号:冒号后紧跟一个非字母数字的一个特殊符号,goto无法识别的标号,可以起到注释作用,::常被用作注释符号
Terminal command execution: Ctrl + Z
2. Common commands
(1) CD switch directory
(2) dir displays the contents of the directory--ls
(3) Ren file or directory rename--MV
(4) MD Create directory--mkdir
(5) Rd Delete Directory--rm
rd movie //删除当前目录下的movie空文件夹rd /s /q d:\test //使用安静模式删除d:\test(除目录本身外,还将删除指定目录下的所有子目录和文件)
(6) Copy copy file--cp
(7) xcopy more powerful copy command
(8) Move file
(9) del Delete file
del test //删除当前目录下的test文件夹中的所有非只读文件(子目录下的文件不删除;删除前会进行确认)del /f test //删除当前目录下的test文件夹汇总的所有文件del /f /s /q test //删除当前目录下的test文件夹中所有文件
3. batch Files
PS F:\windows_cmd_test> cat .\date.bat@echo offcd.>temp.txtecho %date% >> temp.txtecho %time% >> temp.txtcopy temp.txt+insertfile.txt newfile.txt >nul::强制并且不加询问的删除del /f/q temp.txt >nuldel /f/q insertfile.txt >nulren newfile.txt insertfile.txtecho 添加完毕::将当前目录执行dir命令结果保存到dir.txt中dir > dir.txtpausePS F:\windows_cmd_test> .\date.bat添加完毕
Windows common commands and batch processing