Batch Processing Application delay processing

Source: Internet
Author: User

Latency processing is the most disgusting and bad design in Windows batch processing. But there is no way. If you don't know him, you won't be able to use it normally.
Batch processing. A simple column:
For/F % I in (temp.txt) Do (
Set dir = % I
Echo % dir %
)
A simple for loop command reads the name of the directory to be operated from the temp file, which is intuitive and simple, but it is wrong!
The reason is that the interpreter of the batch processing will explain the variable dir before the for loop runs. At this time, the Dir is naturally empty,
The magic is that the set value assignment statement does not work.
To put it bluntly, batch processing does not support local variables by default. So how can we make the local variable take effect? Changed to this:
For/F % I in (temp.txt) Do (
Setlocal enabledelayedexpansion
Set dir = % I
Echo! Dir!
)
Note that local variables are required! Surrounded

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.