|
qinqong
高级用户
   
积分 599
发帖 148
注册 2003-10-30
状态 离线
|
『楼 主』:
求助:间隔时间启动一批文件夹下的批处理文件
使用 LLM 解释/回答一下
我需要启动大约100个文件夹下的批处理程序,文件夹的名字不同,批处理的文件名相同,大约每间隔4,5秒钟就启动一个批处理,文件夹的名字类似以下规则:abc1,abc2,abc3......请各位大虾指点一下怎么写批处理程序。多谢了!
I need to start batch programs in about 100 folders. The folder names are different, but the batch file names are the same. It's about starting one batch every 4 or 5 seconds. The folder names follow a rule like abc1, abc2, abc3... Please, great guys, give me some advice on how to write the batch program. Thanks a lot!
|
|
2006-9-20 10:49 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
|
2006-9-20 11:03 |
|
|
qinqong
高级用户
   
积分 599
发帖 148
注册 2003-10-30
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
如果文件夹改为abc01,abc02,abc03......abc10,abc11,abc12..........呢?
What if the folders are changed to abc01, abc02, abc03......abc10, abc11, abc12..........?
|
|
2006-9-20 11:13 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
Originally posted by qinqong at 2006-9-20 11:13:
如果文件夹改为abc01,abc02,abc03......abc10,abc11,abc12..........呢?
可以, 但比较麻烦.
Originally posted by qinqong at 2006-9-20 11:13:
What if the folders are changed to abc01, abc02, abc03......abc10, abc11, abc12..........?
It's okay, but it's relatively troublesome.
|

业精于勤而荒于嬉,形成于思而毁于随。 |
|
2006-9-20 11:17 |
|
|
namejm
荣誉版主
       batch fan
积分 5226
发帖 1737
注册 2006-3-10 来自 成都
状态 离线
|
    『第 5 楼』:
使用 LLM 解释/回答一下
在『第 2 楼』pengfei 代码的基础上稍加修改,得到如下代码,可以试一下,如果还要启动abc100文件夹下的批处理,请自行修改代码:
@echo off
setlocal enabledelayedexpansion
for /l %%i in (1,1,99) do (
set num=0%%i
set num=!num:~-2!
if exist ".\abc!num!\name.bat" (
ping 127.1 -n 5 >nul 2>nul
call ".\abc!num!\name.bat"
)
)
Last edited by namejm on 2006-9-20 at 11:25 ]
On the basis of the code of pengfei in , a little modification is made to get the following code. You can give it a try. If you also need to start the batch processing in the abc100 folder, you can modify the code by yourself:
@echo off
setlocal enabledelayedexpansion
for /l %%i in (1,1,99) do (
set num=0%%i
set num=!num:~-2!
if exist ".\abc!num!\name.bat" (
ping 127.1 -n 5 >nul 2>nul
call ".\abc!num!\name.bat"
)
)
Last edited by namejm on 2006-9-20 at 11:25 ]
|

尺有所短,寸有所长,学好CMD没商量。
考虑问题复杂化,解决问题简洁化。 |
|
2006-9-20 11:23 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
|
2006-9-20 11:25 |
|
|
qinqong
高级用户
   
积分 599
发帖 148
注册 2003-10-30
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
多谢,批处理好长时间没用,很多东西都忘了,看来还是要经常来这里充充电。
请问setlocal enabledelayedexpansion是什么意思?
Last edited by qinqong on 2006-9-20 at 11:33 ]
Thanks, I haven't used batch processing for a long time, and I've forgotten many things. It seems I still need to often come here to recharge.
What does setlocal enabledelayedexpansion mean?
Last edited by qinqong on 2006-9-20 at 11:33 ]
|
|
2006-9-20 11:29 |
|
|
pengfei
银牌会员
    
积分 1218
发帖 485
注册 2006-7-21 来自 湖南.娄底
状态 离线
|
『第 8 楼』:
使用 LLM 解释/回答一下
setlocal enabledelayedexpansion是启用延迟的环境变量 ~
Last edited by pengfei on 2006-9-20 at 11:38 ]
setlocal enabledelayedexpansion is to enable delayed environment variables ~
Last edited by pengfei on 2006-9-20 at 11:38 ]
|

业精于勤而荒于嬉,形成于思而毁于随。 |
|
2006-9-20 11:35 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
@echo off
for /f "delims=" %%i in ('dir /s /a /b your.bat') do call "%%i" & ping 4 -w 4000 -n 1 2>nul 1>nul
执行时间可以更改-w后面的参数,4000表示4秒
```@echo off
for /f "delims=" %%i in ('dir /s /a /b your.bat') do call "%%i" & ping 4 -w 4000 -n 1 2>nul 1>nul
Execution time can be changed by modifying the parameter after -w, where 4000 represents 4 seconds```
|
|
2006-9-22 01:10 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
3742668斑竹 用 your.bat 不怎么好吧!
Moderator 3742668, using your.bat isn't very good, right!
|
|
2006-9-22 07:41 |
|
|
3742668
荣誉版主
      
积分 2013
发帖 718
注册 2006-2-18
状态 离线
|
『第 11 楼』:
使用 LLM 解释/回答一下
『第 10 楼』:
3742668斑竹 用 your.bat 不怎么好吧!
请详述。
Building 10:
Moderator 3742668, using your.bat is not very good!
Please elaborate.
|
|
2006-9-22 08:27 |
|