当前位置:网站首页>First knowledge of batch processing
First knowledge of batch processing
2022-07-04 04:35:00 【Pineapple bun with butter】
The batch (Batch), Also known as batch scripts . seeing the name of a thing one thinks of its function , Batch processing is batch processing of an object , It is generally considered as a simplified scripting language , It is applied to DOS and Windows In the system . The extension of the batch is bat. There are two common types of batch processing :DOS Batch processing and PS The batch . The following and subsequent introductions are mainly based on DOS Batch based .
The default storage format of batch files is ANSI, That is to use Windows System default encoding format . But we cannot directly create batch files , It is usually created by creating a text file and then changing the extension , Therefore, you need to manually change the encoding format of the file to ANSI Format , In this way, we can prevent Chinese from being garbled .
Interpreter
- Batch processing is case insensitive .
- By default, the batch interpreter reads a line of code , Then explain one line execution
- If the batch interpreter reads parentheses "(“, Think you know the next corresponding ”)", For the end . This method allows the batch interpreter to interpret and execute multiple instructions at one time ( stay if Especially in the sentence )
- CTRL+C You can exit the currently executing batch .
grammar
echo
echo Instructions are the simplest and most common instructions in batch processing . It is equivalent to printing in other languages , Such as Python Of "print".echo You can output the information behind him on the terminal . Pay attention to the output information and echo There needs to be a space between .
echo Hello,World!
Close back display
When we create a batch script and write it, save and run the above instructions , Will find , Every command we write will be displayed on the terminal , Once the script is complex, it will look very ugly , Can we make it not show what commands we wrote ? The answer, of course, is yes . We just need to add a @ Can be realized .
@echo Hello,World!
The problem is coming again , If there are more orders , Isn't it necessary to add one for each @, Is there a more convenient way ? Of course. !
echo off Indicates that echo function is turned off , You can place this command at the top of the script , thus , The echo of the commands written below will be turned off
@echo off
echo Hello,World!
echo Hello,batch!
When echo is turned on @echo on
Output blank lines ( Line break )
In batch ",“、”.“、”:" Wait can follow closely echo Later, it plays the role of outputting blank lines . Note that there must be no spaces , Otherwise it will be output to the screen as information . It can also be used " / ] + \
These symbols replace .
Answer the questions in the order
You can use the pipe command , Use the previous results as input for the following . for example :
@echo off
rd /s c:\abc
pause
In the above script , After execution , Will be displayed :c:\abc, Are you sure (Y/N)?
Because here abc Is a folder that is not empty , So use rd Command to delete , Will ask you Y or N, At this time, you usually need to enter manually . We can modify the script and let the system automatically input Y Confirm :
@echo off
echo Y|rd /s c:\abc
pause
Create documents or add document contents
@echo off
echo 123>myfile.txt
pause
The above command can create a file named myfile.txt The file of , The content of the document is 123, To continue adding content, you can use :
@echo off
echo 456>>myfile.txt
If you want to create an empty file , Then you can use the command of outputting blank lines :
@echo off
echo. >myfile.txt
边栏推荐
- Longest increasing subsequence problem (do you really know it)
- JS realizes the effect of text scrolling marquee
- Precautions for accompanying driving these 23 points should be paid attention to!
- 浅谈JVM的那些事
- 架构训练毕业设计+总结
- 西部数据绿盘、蓝盘、黑盘、红盘和紫盘有什么区别
- Emlog user registration plug-in is worth 80 yuan
- Redis:哈希hash类型数据操作命令
- Pytest基础自学系列(一)
- [Yugong series] go teaching course 002 go language environment installation in July 2022
猜你喜欢
Exploration and practice of eventbridge in the field of SaaS enterprise integration
Graduation project
Leetcode skimming: binary tree 04 (sequence traversal of binary tree)
Keysight n9320b RF spectrum analyzer solves tire pressure monitoring scheme
浅谈JVM的那些事
RHCSA 04 - 进程管理
Redis: hash type data operation command
NFT new opportunity, multimedia NFT aggregation platform okaleido will be launched soon
Boutique website navigation theme whole station source code WordPress template adaptive mobile terminal
Asahi Kasei participated in the 5th China International Import Expo (5th ciie) for the first time
随机推荐
Flink learning 7: application structure
What does software testing do? Find defects and improve the quality of software
疫情远程办公经验分享| 社区征文
I.MX6U-ALPHA开发板(模仿STM32驱动开发实验)
陪驾注意事项 这23点要注意!
Leetcode brush question: binary tree 06 (symmetric binary tree)
“找工作不要太在意工资”,这是我听过最大的谎言
普源DS1000Z系列数字示波器在通信原理实验中的应用方案
Exercises in quantum mechanics
Tcp- simple understanding of three handshakes and four waves
苹果CMS仿西瓜视频大气响应式视频模板源码
Operation of ES6
RHCSA 01 - 创建分区与文件系统
Leetcode brush questions: binary tree 05 (flip binary tree)
深入解析结构化异常处理(SEH) - by Matt Pietrek
Apple CMS imitation watermelon video atmospheric response video template source code
[Yugong series] go teaching course 001 in July 2022 - Introduction to go language premise
Asahi Kasei participated in the 5th China International Import Expo (5th ciie) for the first time
Keysight N9320B射频频谱分析仪解决轮胎压力监测方案
Redis: hash type data operation command