批处理变量不递增!
SET /a _count = 1
set /p drive=Please type drive name[C/D/E/F/..]?:
echo Creating Directory %drive%:\AKI_Data_Feeds
mkdir %drive%:\AKI_Data_Feeds
for /f %%a in (companyList.txt) do (
echo Creating Directory %drive%:\AKI_Data_Feeds\%%a
mkdir %drive%:\AKI_Data_Feeds\%%a
for /f %%b in (branch1.txt) do (
echo Creating Directory %drive%:\AKI_Data_Feeds\%%a\%%b
mkdir %drive%:\AKI_Data_Feeds\%%a\%%b
if "%_count%"=="1" (
for /f %%c in (branch1_1.txt) do (
echo Creating Directory %drive%:\AKI_Data_Feeds\%%a\%%b\%%c
mkdir %drive%:\AKI_Data_Feeds\%%a\%%b\%%c
for /f %%e in (branch2.txt) do (
echo Creating Directory %drive%:\AKI_Data_Feeds\%%a\%%b\%%c\%%e
mkdir %drive%:\AKI_Data_Feeds\%%a\%%b\%%c\%%e
)
)
SET /a _count +=1
echo %_count%
)
if "%_count%"=="2" (
for /f %%d in (branch1_2.txt) do (
echo Creating Directory %drive%:\AKI_Data_Feeds\%%a\%%b\%%d
mkdir %drive%:\AKI_Data_Feeds\%%a\%%b\%%d
for /f %%e in (branch2.txt) do (
echo Creating Directory %drive%:\AKI_Data_Feeds\%%a\%%b\%%c\%%e
mkdir %drive%:\AKI_Data_Feeds\%%a\%%b\%%c\%%e
)
)
SET /a _count +=1
)
)
)
echo Successfully created.
pause
_count 没有增加
SET /a _count = 1
set /p drive=Please type drive name[C/D/E/F/..]?:
echo Creating Directory %drive%:\AKI_Data_Feeds
mkdir %drive%:\AKI_Data_Feeds
for /f %%a in (companyList.txt) do (
echo Creating Directory %drive%:\AKI_Data_Feeds\%%a
mkdir %drive%:\AKI_Data_Feeds\%%a
for /f %%b in (branch1.txt) do (
echo Creating Directory %drive%:\AKI_Data_Feeds\%%a\%%b
mkdir %drive%:\AKI_Data_Feeds\%%a\%%b
if "%_count%"=="1" (
for /f %%c in (branch1_1.txt) do (
echo Creating Directory %drive%:\AKI_Data_Feeds\%%a\%%b\%%c
mkdir %drive%:\AKI_Data_Feeds\%%a\%%b\%%c
for /f %%e in (branch2.txt) do (
echo Creating Directory %drive%:\AKI_Data_Feeds\%%a\%%b\%%c\%%e
mkdir %drive%:\AKI_Data_Feeds\%%a\%%b\%%c\%%e
)
)
SET /a _count +=1
echo %_count%
)
if "%_count%"=="2" (
for /f %%d in (branch1_2.txt) do (
echo Creating Directory %drive%:\AKI_Data_Feeds\%%a\%%b\%%d
mkdir %drive%:\AKI_Data_Feeds\%%a\%%b\%%d
for /f %%e in (branch2.txt) do (
echo Creating Directory %drive%:\AKI_Data_Feeds\%%a\%%b\%%c\%%e
mkdir %drive%:\AKI_Data_Feeds\%%a\%%b\%%c\%%e
)
)
SET /a _count +=1
)
)
)
echo Successfully created.
pause
_count is not getting incremented
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你需要延迟扩展来解决这个问题。
由于在解析块时所有百分比变量都会扩展,因此它们的值似乎没有变化。
通过延迟扩展,变量在执行时扩展。
You need the delayed expansion to solve this.
As all percent variables expands while a block is parsed, their values seems to be unchanged.
With delayed expansion the variables are expanded at execution time.