在回显命令的迭代之间切换(批处理文件)

时间:2019-06-27 01:36:54

标签: batch-file

我正在尝试创建一个有趣的炸弹病毒,该病毒会闪烁一堆带有一组文本的窗口,然后经过一定次数的迭代后会闪烁一堆带有一组单独的文本的窗口,来回移动。我无法从一组文本切换到另一组文本。它只是一直停留在一个集合上。这是我到目前为止所得到的。

start 123.bat

echo off
set /a count=1
set /a coun=1
:first
timeout /t 1
echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS

echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS

echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS

echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS

echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS

echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS

echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS

echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS

echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS

echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS

echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS

echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS
set /a count=%count%+1
if %count%==25 (goto next)
goto first

:next
timeout /t 1
echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED

echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED   

echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED

echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED   

echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED

echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED   

echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED

echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED   

echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED

echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED   

echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED

echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET      YOUR EYES CHECKED 
set /a coun=%coun%+1
if %coun%==25 (goto first)
goto next 

在此工作上的任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

问题是countcoun变量应在每次执行命令块时每次初始化为1 ,也就是说,您可以插入一个附加标签,例如:first0,并将set count=1放在其下方(在其下方带有:first标签),并修复相应的 goto first命令。 :next标签和coun变量也是如此。顺便说一句,以这种方式,不再需要在两个循环中使用不同的变量...

但是,使用for /L命令更简单:

@echo off

:first
for /L %%f in (1,1,25) do (
   timeout /t 1
   for /L %%i in (1,1,12) do echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS
)

:next
for /L %%n in (1,1,25) do (
   timeout /t 1
   for /L %%i in (1,1,12) do echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED
)

goto first

您还可以使用for /L命令创建没有循环值的无限循环

@echo off

for /L %%x in () do (

for /L %%f in (1,1,25) do (
   timeout /t 1
   for /L %%i in (1,1,12) do echo FOLLOW THIS   FOLLOW THIS    FOLLOW THIS   FOLLOW THIS   FOLLOW THIS        FOLLOW THIS
)

for /L %%n in (1,1,25) do (
   timeout /t 1
   for /L %%i in (1,1,12) do echo THEN GET YOUR EYES CHECKED    THEN GET YOUR EYES CHECKED    THEN GET     YOUR EYES CHECKED
)

)