batch-file - 我如何将 11 添加到 %%i?

标签 batch-file batch-rename

我试过了

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

它只是尝试将 text_1.txt 重命名为 worked_1+11.txt 我该怎么做?

提前致谢

最佳答案

根据我的理解,你想要一个数学加法的问题。所以你需要 delayed expansionset/a :

@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
)

关于batch-file - 我如何将 11 添加到 %%i?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28589362/

相关文章:

javascript - 通过Chrome执行bat文件

batch-file - 如何在 Windows 批处理文件中为 ffmpeg 输出的重复文件名添加后缀?

batch-file - 如何在 .BAT 文件中运行多个 .BAT 文件

batch-file - 如何在批处理文件中交换我的主显示器?

linux - Linux 下批量音乐目录重命名脚本/命令 (bash)

linux - 使用 zmv 或重命名将具有路径名的文件重命名为正确的大小写

java - 重命名目录中多个文件的脚本或java程序

Linux:如何为保持扩展名的文件添加后缀

batch-file - 如何用数字重命名文件夹(即Folder1、Folder2等......)

windows - Windows批处理下无法使用 "git.exe fetch origin"内的管道