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-07-06 11:17
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How do I use FOR..? View 814 Replies 4
Original Poster Posted 2010-04-13 22:57 ·  中国 广东 深圳 电信
初级用户
Credits 38
Posts 16
Joined 2010-04-13 00:36
16-year member
UID 164446
Gender Male
Status Offline
Floor 2 Posted 2010-04-14 01:07 ·  美国 惠普HP
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
How many lines are there in a.txt exactly?
Floor 3 Posted 2010-04-14 03:27 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
Floor 4 Posted 2010-04-14 05:33 ·  中国 吉林 延边朝鲜族自治州 延吉市 电信
银牌会员
★★★
正在学习中的菜鸟...
Credits 1,039
Posts 897
Joined 2009-03-01 15:34
17-year member
UID 140302
Gender Male
From 在地狱中仰望天堂
Status Offline
There are many ways. For example:
@echo off&setlocal enabledelayedexpansion
for /f "delims=" %%a in (123.txt) do set a=%%a&for /l %%b in (1,1,9) do if not "!a:%%b=!"=="!a!" copy %%b.txt d:\ >nul

You can also use findstr , etc...
Floor 5 Posted 2010-04-14 11:49 ·  中国 广东 深圳 宝安区 电信
初级用户
Credits 38
Posts 16
Joined 2010-04-13 00:36
16-year member
UID 164446
Gender Male
Status Offline
For example, the contents of 123.txt are:
Serial number: DHOHHQO1HFA
after posting ih9ihaf reply
somewhere also FGIOYA
And 1-9 was just an example, meaning there are several such things... in reality it's a string, like WORDS, DOS, and so on.
Forum Jump: