【发布时间】:2014-04-14 11:48:08
【问题描述】:
您好,我正在处理一个小批处理文件,该文件将我的重命名文件放在一个目录中,到目前为止循环正在运行,但我想在我的计数器结果前面创建一个 0,如下所示:
setlocal ENABLEDELAYEDEXPANSION
SET /A counter=0
for %%A IN (*.txt) DO (
SET /A counter+=1
copy "%%A" "directory/%%A.!counter!.txt"
)
这完美输出为:
tvscriptmonday.txt => TVscriptmonday.1.txt tvscripttuesday.txt => TVscripttuesday.2.txt但我想作为输出:
TVscriptmonday.01.txt
TVscripttuesday.02.txt
我尝试使用IF 命令:
if !counter! <9 set counter=0!counter!
但不知何故我无法让它工作,有什么想法吗?
【问题讨论】:
-
总之,使用
if !counter! lss 9 set counter=0!counter!
标签: windows loops batch-file counter