China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-10 08:59
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Batch file to exit automatically View 693 Replies 1
Original Poster Posted 2008-11-09 21:22 ·  中国 广东 汕头 电信
新手上路
Credits 7
Posts 7
Joined 2008-11-03 19:25
17-year member
UID 129895
Gender Male
Status Offline
The batch commands are as follows:
@echo off&setlocal enabledelayedexpansion
set m=1
for /f "delims=" %%i in (s.txt) do (
set /a n+=1
if !n! leq 20 echo %%i>>s_!m!.txt
if !n! equ 20 set n=0&set /a m+=1
)
echo Done!
set /a dis=1
:11ss
for /f %%i in (s_%dis%.txt) do @ start %%i.bat
s.exe tcp 192.168.0.1 192.168.0.200 445 10 /save
set /a dis=%dis%+1
goto 11ss





I'd like to ask, after splitting s.txt into N files,
the script below runs the split files.
How can I make it automatically exit when it reaches the end and there are no more files???
For example, if s.txt gets split into 5 files,
how can I make the later script automatically exit after start s_5.txt???
How should I modify or rewrite it????
5 is not a fixed number...
Also,
while exiting, delete the files split out from s.txt?
Floor 2 Posted 2008-11-10 00:28 ·  中国 江西 赣州 电信
银牌会员
★★★★
Credits 2,025
Posts 1,122
Joined 2007-09-05 20:15
18-year member
UID 96653
Gender Male
Status Offline
@echo off&setlocal enabledelayedexpansion 
set m=1
for /f "delims=" %%i in (s.txt) do (
set /a n+=1
if !n! leq 20 echo %%i>>s_!m!.txt
if !n! equ 20 set n=0&set /a m+=1
)
echo Done!

set dis=1

:11ss
for /f %%i in (s_%dis%.txt) do start %%i.bat
s.exe tcp 192.168.0.1 192.168.0.200 445 10 /save

set /a dis+=1
if exist s_%dis%.txt goto 11ss

del s_*.txt
Forum Jump: