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-09-28 16:07
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » [Help] Problem with Comparing Two Files View 3,807 Replies 52
Floor 46 Posted 2008-07-10 00:11 ·  中国 江苏 苏州 电信
高级用户
★★
五星老土
Credits 558
Posts 172
Joined 2003-02-09 00:00
23-year member
UID 881
Gender Male
From 江苏
Status Offline
Originally posted by zw19750516 at 2008-7-10 12:09 AM:

Is there something wrong with my eyes? I've read the code on floor 24 many times, but I can't see a single "defined". Lao Tu, can you take a look again?



Sorry, I should have looked at the code on floor 24 plus the code on floor 7. I made a mistake.

Also, there might be an issue with missing or extra parentheses in your code. I can't tell.

[ Last edited by quya on 2008-7-10 at 12:17 AM ]
我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已.
Floor 47 Posted 2008-07-10 00:23 ·  中国 湖南 株洲 电信
金牌会员
★★★★
永远的学习者
Credits 3,105
Posts 1,276
Joined 2008-03-08 13:00
18-year member
UID 112398
Gender Male
Status Offline
Oh, there's neither more nor less. I can't see it either.
Don't think about it anymore, going to sleep.

[ Last edited by zw19750516 on 2008-7-10 at 12:27 AM ]
批处理之家新域名:www.bathome.net
Floor 48 Posted 2008-07-10 00:30 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
The number of loops for the code on floor 39 to 1.txt is equal to the number of lines in 2.txt multiplied by the number of lines in 1.txt, so the efficiency is much lower.

[ Last edited by 26933062 on 2008-7-10 at 12:31 AM ]
致精致简!
Floor 49 Posted 2008-07-10 00:46 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
Has the thread starter solved the problem?
致精致简!
Floor 50 Posted 2008-07-10 00:48 ·  中国 江苏 苏州 电信
高级用户
★★
五星老土
Credits 558
Posts 172
Joined 2003-02-09 00:00
23-year member
UID 881
Gender Male
From 江苏
Status Offline
Originally posted by 26933062 at 2008-7-10 12:30 AM:
Has the landlord's problem been solved?


You claimed that you didn't even graduate from junior high school, but now I simply can't believe it. How can someone who didn't graduate from junior high school write programs so skillfully? You've confused me, someone who claims to have at least a college education, completely.

If I were ten years younger, I don't think I would come here for help. It's embarrassing. At most, I would stay up all night to thoroughly understand all the commands and then figure out a way, but I'm getting old, and indeed, I can't do it anymore.

Going to sleep now. I've learned a lot today. One learns until one dies. Thanks everyone!

[ Last edited by quya on 2008-7-10 at 12:52 AM ]
我怎么找不到一个比我注册日期早的人? 难道我是传说中的超级管理员? 其实我只是个潜水冠军而已.
Floor 51 Posted 2008-07-10 01:01 ·  中国 江苏 常州 武进区 电信
银牌会员
★★★
Credits 2,404
Posts 946
Joined 2005-09-08 13:44
21-year member
UID 42345
Status Offline
Still, Xiao Lou's looks better. Compare with yours.

@echo off&setlocal enabledelayedexpansion
for /f "tokens=1*" %%i in (1.txt) do set "%%j=%%i"
for /f "delims=" %%a in (2.txt) do (
if /i "%%~xa"==".cat" (
for /f "tokens=1*" %%i in ('crc32 %%~fsa') do if defined %%j >>crc.txt echo !%%j! %%j %%i)else (
expand %%~fsa %temp%\%%~na.cat
for /f "tokens=1*" %%i in ('crc32 %temp%\%%~na.cat') do if defined %%j >>crc.txt echo !%%j! %%j %%~fsa
))
pause
简单!简单!再简单!
Floor 52 Posted 2008-07-10 01:11 ·  中国 湖南 娄底 电信
银牌会员
★★★
Credits 2,268
Posts 879
Joined 2006-12-19 16:23
19-year member
UID 73968
Gender Male
Status Offline
I took another look at the description in the top post, the original poster's sentence.
Now I get a variable value, such as HEDY, which is the first value in the line in file 1.txt.
I perform a CRC32 check on the files in the path in 2.txt (if it's a compressed file, first EXPAND it), run CRC32.EXE, assume that the CRC output result is the second Token in the first line, and then compare it with the value in the second line of file 1.txt. IF FIND, then assign the corresponding path to a variable.

It seems to be to find the required file name according to the value of a variable, not to compare all.
The following: the value of str is the one to be found. It can be multiple, separated by spaces.
:

@echo off&setlocal enabledelayedexpansion
set str=HEDY LEGEND
for /f "tokens=1* delims= " %%a in (1.txt) do set "%%a=%%b"
for /f "delims==" %%i in (2.txt) do (
if /i %%~xi==.cat (
for /f "delims=" %%j in ('crc32 %%~fsi') do set "var=%%j"
) else (
expand %%~fsi %temp%\oembios.cat
for /f "tokens=2" %%j in ('crc32 %temp%\oembios.cat') do set "var=%%j"
del/q %temp%\oembios.cat >nul 2>nul
)
for %%a in (%str%) do if /i "!var!"=="!%%a!" echo %%a !var! %%i
)
pause


[ Last edited by 26933062 on 2008-7-10 at 01:21 AM ]
致精致简!
Floor 53 Posted 2008-07-10 17:12 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Originally posted by quya at 2008-7-9 13:53:
I have installed the VOL version of XP on my computer. Now I want to change it to the OEM version. My motherboard has OEM characteristics, and I have a large number of OEM BIOS files available to replace the files required by the system. To find the accurate OEM BIOS files, I put them in specific folders one by one so that the program can automatically find them.


It's a bit messy. I'll give you a solution for the above problem (requires crc32sum.exe)



@echo off
for /f "delims=" %%a in ('dir /s/a-d/b D:\*.CA*') do call :xxx "%%a"
pause

:xxx
set "FliePath=%~dp1"
set "Flie=%~nx1"
if "%Flie:~-1%"=="_" (
EXPAND "%~1" "%temp%\OEMBIOS.CAT" >nul
for /f "tokens=1 delims=* " %%i in ('crc32sum.exe -b "%temp%\OEMBIOS.CAT"') do set "crc32=%%i"
) else (
for /f "tokens=1 delims=* " %%i in ('crc32sum.exe -b "%~1"') do set "crc32=%%i"
)
for /f "tokens=1 delims= " %%k in ('type 1.txt^|find /i "%crc32%"') do echo 文件"%~1" 对应品牌%%k


Function description: Enumerate CA* extensions on drive D. If the extension is CA_, use EXPAND to extract to the temporary folder and then use crc32sum.exe to verify. Otherwise, directly use crc32sum.exe to verify. Assign the verification value to the variable crc32. Finally, filter and display the OEM results. crc32sum.exe can be downloaded from my cloud disk.
http://fastslz.cech.com.cn/#show=file
This is my execution result
File "D:\oembios\XP_ACER_OEM\OEMBIOS.CA_" corresponds to brand Acer
File "D:\oembios\XP_ASUS_OEM\OEMBIOS.CA_" corresponds to brand Asus
File "D:\oembios\XP_COMPAQ_OEM\OEMBIOS.CA_" corresponds to brand Compaq
File "D:\oembios\XP_DELL_OEM\OEMBIOS.CA_" corresponds to brand Dell
File "D:\oembios\XP_HP_OEM\OEMBIOS.CA_" corresponds to brand Hewlett-Packard
File "D:\oembios\XP_IBM_OEM\OEMBIOS.CA_" corresponds to brand IBM
File "D:\oembios\XP_IBM_OEM\OEMBIOS.CA_" corresponds to brand IBM
File "D:\oembios\XP_Lenovo_OEM\OEMBIOS.CA_" corresponds to brand LEGEND
File "D:\oembios\XP_Lenovo_OEM\OEMBIOS.CA_" corresponds to brand LEGEND
File "D:\oembios\XP_SONY_OEM\OEMBIOS.CA_" corresponds to brand Sony
Press any key to continue. . .
第一高手 第二高手
我的小站
Forum Jump: