例子
这将针对第一个数字进行X
,我将留下一些供您开发和学习。:)
@echo off
setlocal EnableExtensions EnableDelayedExpansion
echo LeftXRight Gen
set /p "Left=Left = "
set /p "Right=Right = "
set /p "Start=Begin = "
set /p "End=End = "
>output.txt ( <nul set /p "=" )
for /L %%A in (%Start%, 1, %End%) do (
set "X=00%%A"
echo !Left!!X:~-3!!Right!>>output.txt
)
endlocal
输出
LeftXRight Gen
Left = http://user:password@website.com/members/sets/
Right = /somethingfixed.zip
Start = 1
End = 10
输出.txt
http://user:password@website.com/members/sets/001/somethingfixed.zip
http://user:password@website.com/members/sets/002/somethingfixed.zip
http://user:password@website.com/members/sets/003/somethingfixed.zip
http://user:password@website.com/members/sets/004/somethingfixed.zip
http://user:password@website.com/members/sets/005/somethingfixed.zip
http://user:password@website.com/members/sets/006/somethingfixed.zip
http://user:password@website.com/members/sets/007/somethingfixed.zip
http://user:password@website.com/members/sets/008/somethingfixed.zip
http://user:password@website.com/members/sets/009/somethingfixed.zip
http://user:password@website.com/members/sets/010/somethingfixed.zip
更新
为问题添加了这个完整的解决方案。
@echo off
setlocal EnableExtensions EnableDelayedExpansion
echo LeftXMidXRight Gen
set /p "Left=Left = "
set /p "Middle=Middle = "
set /p "Right=Right = "
set /p "Start=Begin = "
set /p "End=End = "
>output.txt ( <nul set /p "=" )
for /L %%A in (%Start%, 1, %End%) do (
set "X=00%%A"
echo !Left!!X:~-3!!Middle!!X:~-3!!Right!>>output.txt
)
endlocal
例子
LeftXMidXRight Gen
Left = http://user:password@website.com/members/sets/
Middle = /somethingfixed-
Right = .zip
Begin = 1
End = 150
输出.txt
http://user:password@website.com/members/sets/001/somethingfixed-001.zip
http://user:password@website.com/members/sets/002/somethingfixed-002.zip
...
http://user:password@website.com/members/sets/150/somethingfixed-150.zip