中国DOS联盟论坛

China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --
Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
Guest | Log in | Register | Members | Search | China DOS Union
中国DOS联盟论坛
The time now is 2026-08-02 03:36
48,037 topics / 350,122 posts / today 2 new / 48,250 members
DOS批处理 & 脚本技术(批处理室) » Help: Start a batch of batch files in a folder at intervals
Printable Version  2,093 / 10
Floor1 qinqong Posted 2006-09-20 10:49
高级用户 Posts 148 Credits 599
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!
Floor2 pengfei Posted 2006-09-20 11:03
银牌会员 Posts 485 Credits 1,218 From 湖南.娄底
I wonder if it meets the LZ's requirements.
@echo off
for /l %%i in (1,1,100) do (
if exist ".\abc%%i\name.bat" (
ping 127.1 -n 5 >nul 2>nul
call ".\abc%%i\name.bat"
)
)

[ Last edited by pengfei on 2006-9-20 at 11:06 ]
Floor3 qinqong Posted 2006-09-20 11:13
高级用户 Posts 148 Credits 599
What if the folders are changed to abc01, abc02, abc03......abc10, abc11, abc12..........?
Floor4 pengfei Posted 2006-09-20 11:17
银牌会员 Posts 485 Credits 1,218 From 湖南.娄底
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.
Floor5 namejm Posted 2006-09-20 11:23
荣誉版主 Posts 1,737 Credits 5,226 From 成都
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:


[ Last edited by namejm on 2006-9-20 at 11:25 ]
Floor6 pengfei Posted 2006-09-20 11:25
银牌会员 Posts 485 Credits 1,218 From 湖南.娄底
Hehe~ Brother namejm has already fixed it!

@echo off
setlocal enabledelayedexpansion
for /l %%i in (1,1,108) do (
set files=%%i
if %%i LSS 10 set files=0%%i
if exist ".\abc!files!\name.bat" (
ping 127.1 -n 5 >nul 2>nul
call ".\abc!files!\name.bat"
)
)

[ Last edited by pengfei on 2006-9-21 at 02:31 ]
Floor7 qinqong Posted 2006-09-20 11:29
高级用户 Posts 148 Credits 599
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 ]
Floor8 pengfei Posted 2006-09-20 11:35
银牌会员 Posts 485 Credits 1,218 From 湖南.娄底
setlocal enabledelayedexpansion is to enable delayed environment variables ~

[ Last edited by pengfei on 2006-9-20 at 11:38 ]
Floor9 3742668 Posted 2006-09-22 01:10
荣誉版主 Posts 718 Credits 2,013
```@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```
Floor10 vkill Posted 2006-09-22 07:41
金牌会员 Posts 1,744 Credits 4,103 From 甘肃.临泽
Moderator 3742668, using your.bat isn't very good, right!
Floor11 3742668 Posted 2006-09-22 08:27
荣誉版主 Posts 718 Credits 2,013
Building 10:

Moderator 3742668, using your.bat is not very good!

Please elaborate.
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023