中国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-12 00:05
47,811 topics / 349,897 posts / today 0 new / 48,256 members
DOS批处理 & 脚本技术(批处理室) » Need to compare the contents of two text files?
Printable Version  968 / 3
Floor1 lbccyxs Posted 2010-07-29 10:42
初级用户 Posts 27 Credits 54
Hello everyone! Please help take a look at how this should be written.
A.TXT contents
QQ Speed
QQ Island
QQ Fengshenji
QQ Huaxia
Baby Tank
Snowstorm Love Sky
...........

B.TXT contents
QQ Island
QQ Speed
Speed
Baby Tank
Baby

The contents of A.TXT are the standard. For each line in B.TXT, if it is different from A.TXT, find it and put it into C.TXT (for example, Speed and Baby)

[ Last edited by lbccyxs on 2010-7-29 at 10:51 ]
Floor2 keygohuang Posted 2010-07-30 12:49
新手上路 Posts 1 Credits 1
@echo off
:: Extract the differences between the two files into some file
::
cd.>3.txt
for /f "tokens=1* delims=:" %%i in ('findstr /n . 1.txt') do (
for /f "tokens=1* delims=:" %%x in ('findstr /n . 2.txt') do (
if %%i equ %%x if not "%%j"=="%%y" (>>3.txt echo 1:%%j&>>3.txt echo 2:%%y&>>3.txt echo.)
)
)




------------------------
http://www.jb51.net/list/list_106_2.htm
Floor3 lbccyxs Posted 2010-08-03 11:16
初级用户 Posts 27 Credits 54
This one is relatively slow (mainly because there are a lot of games), but it can meet the requirement. The purpose is to delete expired games.
cd.>c.bat
for /f "tokens=*" %%i in (a.txt) do (
find "%%i" b.txt || >>c.bat echo RD /S/Q K:\网络游戏\%%i)
del 1.txt&del a.txt&del b.txt
notepad c.bat

[ Last edited by lbccyxs on 2010-8-3 at 22:32 ]
Floor4 HAT Posted 2010-08-04 00:46
版主 Posts 5,017 Credits 9,023
Wouldn't a single line of findstr do it?
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023