Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/batch-file/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Batch file 如何将11添加到%%I?_Batch File_Batch Rename - Fatal编程技术网

Batch file 如何将11添加到%%I?

Batch file 如何将11添加到%%I?,batch-file,batch-rename,Batch File,Batch Rename,我试过了 它只是尝试将文本_1.txt重命名为工作的_1+11.txt 我该如何正确地做呢 提前谢谢因为我理解了你想要一个数学加法的问题。所以你需要和设置/a: set /p input2= FOR /L %%i IN (1,1,%input2%) do ren text_%%i.txt worked_%%i+11.txt 为了好玩,我决定编写一个不使用延迟扩展且不需要调用的解决方案。但通常我会像Npcmaka那样使用延迟扩展 @echo off set /p input2=provide

我试过了

它只是尝试将文本_1.txt重命名为工作的_1+11.txt 我该如何正确地做呢


提前谢谢

因为我理解了你想要一个数学加法的问题。所以你需要和
设置/a

set /p input2=
FOR /L %%i IN (1,1,%input2%) do ren text_%%i.txt worked_%%i+11.txt

为了好玩,我决定编写一个不使用延迟扩展且不需要调用的解决方案。但通常我会像Npcmaka那样使用延迟扩展

@echo off

set /p input2=provide a number
setlocal enableDelayedExpansion
FOR /L %%i IN (1;1;%input2%) do (
 set num=%%i
 set /a nump11=num+11
 ren text_%%i.txt worked_!nump11!.txt
)

是的,这很有效,非常感谢您的快速回答:)您不需要num变量。您可以将nump11直接定义为
%%i+11
@echo off
set /p input2=
set /a end=input2+11
for /f "tokens=1,2 delims=: " %%A in (
  '(for /l %%N in (12 1 %end%^) do @echo %%N^)^|findstr /n "^"'
) do echo ren text%%A.txt worked_%%B.txt