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