标题: 想问一个无厘头循环的批处理,请高手来帮忙!
[打印本页]
作者: qq331407896
时间: 2010-1-18 11:55
标题: 想问一个无厘头循环的批处理,请高手来帮忙!
小弟想请教一个问题。
有一个叫5th的程序,还有N个这个程序的ini和dat,放在zyd这个文件夹里面。
现在我要运行5th这个程序N次,每次运行都要用不同的ini和dat,我写了一个批处理
del .\5th.ini
del .\5th.dat
copy .\zyd\1.ini .
copy .\zyd\1.dat .
ren .\1.ini 5th.ini
ren .\1.dat 5th.dat
.\5th.exe
del .\5th.ini
del .\5th.dat
copy .\zyd\2.ini .
copy .\zyd\2.dat .
ren .\2.ini 5th.ini
ren .\2.dat 5th.dat
.\5th.exe
del .\5th.ini
del .\5th.dat
copy .\zyd\3.ini .
copy .\zyd\3.dat .
ren .\3.ini 5th.ini
ren .\3.dat 5th.dat
.\5th.exe
......
就是将zyd文件夹里的1,2,3,4....N个ini和dat依次复制到程序目录下,重命名成5th.ini 5th.dat ,运行程序。退出程序后再复制2,3,4...N 个ini和dat,继续运行程序。
虽然这么写下去,也可以达到运行程序N次的目的,但是我想问下能否借助一些循环命令例如for 写一个简短的批处理。
小弟我对dos的理解是半桶水,特地上此来请教各位大哥大姐们。
如果能把代码告诉小弟,感激不尽。谢谢
Last edited by qq331407896 on 2010-1-18 at 11:58 ]
作者: q1x2x3
时间: 2010-1-19 16:53
@echo off
if exist 333.txt (set na=333) else (echo 333.txt not exist&pause>nul&exit)
:cout
set /a na+=1
if exist %na%.txt (goto cout) else (copy 333.txt %na%.txt&exit)
给你看一段批处理怎么写自己看着办,这一段是C目录下有333.txt文件的话每打开一次就会递增一个数字,打开第一次建立334.txt,第二次335.txt
我想你知道该怎么改了吧,授人以渔,不授人以鱼