2
我用下面的代码,以创建从第一4个字符集电极文本文件的值的目录如何改变变量值内循环以分批
@echo off & setlocal enabledelayedexpansion
:loop
set /P txt_file=<Collector.txt
Set collector_id=!txt_file:~0,4!
:: check for existence of [OutputFolder]
:: if [OutputFolder] doesn't exist, create it
if not exist %collector_id% (
echo folder %collector_id% not found
echo creating folder %collector_id%
md %collector_id%
)
xcopy *.txt %collector_id% /v
Del *.txt
goto loop
欲连续地执行上述循环以检查当前目录是否为空。如果不是,我想制作一个目录,如果不存在,则命名为collector.txt的前4个字符。
如果该目录不为空,则一切正常。当上述循环并将collector.txt添加到当前目录时,collector_id不会更改。
我在哪里错了?
有没有其他办法,期待无限循环来做到这一点?
另请参阅[此问题](http://stackoverflow.com/questions/1199931/how-expand-a-cmd-shell-variable-twice-recursively)。 –