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-05 05:17
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] File operations View 706 Replies 4
Original Poster Posted 2007-04-14 05:27 ·  中国 浙江 宁波 电信
初级用户
Credits 62
Posts 24
Joined 2007-03-17 09:34
19-year member
UID 82057
Gender Male
Status Offline
In one directory there are the following files:
abc.ncmm_0
abc.ncmm_1
abc.ncmm_2
abc.ncmm_3
abc.ncmm_4
abc.ncmm_5
I wrote a piece of code to display the specified content in each file:
@echo off
for /f "delims=" %%i in ('dir /b /on *ncmm*') do (
for /f "delims=!" %%a in ('findstr ! %%i') do (
echo %%a
)
)
pause
The displayed content is as follows:
<td width=83 align=center rowspan=2>IN102</td> <
<td width=83 align=center rowspan=2>IN103</td> <
<td width=83 align=center rowspan=2>IN104</td> <
<td width=83 align=center rowspan=2>IN105</td> <
<td width=83 align=center rowspan=2>IN105</td> <
<td width=83 align=center rowspan=2>IN106</td> <
There are two IN105 entries. Now I want to delete the file abc.ncmm_3 corresponding to the first IN105, and then merge the remaining files. What exactly should I do? Thanks.
Floor 2 Posted 2007-04-14 13:57 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Floor 3 Posted 2007-04-14 21:23 ·  中国 浙江 宁波 电信
初级用户
Credits 62
Posts 24
Joined 2007-03-17 09:34
19-year member
UID 82057
Gender Male
Status Offline
I didn't explain it clearly. The situation is like this: these ncmm files are output by another program. The number of files is random, maybe three or five, maybe dozens. The numeric suffixes of files whose specified content is duplicated are consecutive. It could be 1 2 3, or it could be 8 9, but there will never be a case like 2 and 4 having the same content (if that happens, then 2 3 4 would all have the same content).
Floor 4 Posted 2007-04-15 00:09 ·  中国 湖北 武汉 电信
版主
★★★★★
Credits 11,386
Posts 4,938
Joined 2006-07-23 17:10
20-year member
UID 59080
Status Offline
Oh, my understanding was a bit off too.

One more question: do you want to merge the filtered files, or merge the original files?
Floor 5 Posted 2007-04-15 01:01 ·  中国 浙江 宁波 电信
初级用户
Credits 62
Posts 24
Joined 2007-03-17 09:34
19-year member
UID 82057
Gender Male
Status Offline
Merge the filtered files
Forum Jump: