中国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-09-28 16:07
47,813 topics / 349,918 posts / today 0 new / 48,277 members
DOS批处理 & 脚本技术(批处理室) » [Help] Problem with Comparing Two Files
Printable Version  3,805 / 52
Floor16 26933062 Posted 2008-07-09 18:59
银牌会员 Posts 879 Credits 2,268
If the code on floor 10 is feasible, then the efficiency should be higher.
:
Floor17 quya Posted 2008-07-09 21:27
高级用户 Posts 172 Credits 558 From 江苏
The code above doesn't work, but I still sincerely thank everyone.

I want to start with something simple. I have a very small CRC32 program

Download it from my ftp://quya.2mydns.com/crc32.com

This program runs under code page 437 and doesn't support long file names or directories with spaces, but the following code can get the correct result.



The content of file 2.txt is as follows:

G:\IBM\oembios.cat
G:\IBM\OEMBIOS.CA_
G:\WXPOEM\IBM\I386\OEMBIOS.CA_
G:\xpdos\I386\OEMBIOS.CA_
G:\xpdos\WXPOEM\ACER\OEMBIOS.CAT
G:\xpdos\WXPOEM\ASUS\OEMBIOS.CA_
G:\xpdos\WXPOEM\DELL\OEMBIOS.CAT
G:\xpdos\WXPOEM\HPQ\OEMBIOS.CAT
G:\xpdos\WXPOEM\IBM\OEMBIOS.CAT
G:\xpdos\WXPOEM\LENOVO\OEMBIOS.CAT
F:\e\Backup\Tools\OEM 5 files\Acer\OEMBIOS.CA_
F:\e\Backup\Tools\OEM 5 files\COMPAQ\OEMBIOS.CA_
F:\e\Backup\Tools\OEM 5 files\HEDY\OEMBIOS.CA_
F:\e\Backup\Tools\OEM 5 files\HP\OEMBIOS.CA_
F:\e\Backup\Tools\OEM 5 files\IBM\OEMBIOS.CA_
F:\e\Backup\Tools\OEM 5 files\Legend\OEMBIOS.CA_
F:\e\Backup\Tools\OEM 5 files\SAMSUNG\OEMBIOS.CA_
F:\e\Backup\Tools\OEM 5 files\Sony\OEMBIOS.CA_
F:\FTP\Up\2003ent\OEMBIOS.CA_
E:\OEM files\ACER\OEMBIOS.CAT
E:\OEM files\LEGEND\OEMBIOS.CA_


The running result is as follows:

G:\IBM\oembios.cat D7A77612
C:\WINXP\TEMP\oembios.cat D7A77612
C:\WINXP\TEMP\oembios.cat D7A77612
C:\WINXP\TEMP\oembios.cat 90BBDCA0
G:\xpdos\WXPOEM\ACER\OEMBIOS.CAT 717B6EF3
C:\WINXP\TEMP\oembios.cat B20C65BF
G:\xpdos\WXPOEM\DELL\OEMBIOS.CAT B6F0EEFD
G:\xpdos\WXPOEM\HPQ\OEMBIOS.CAT CD4E1902
G:\xpdos\WXPOEM\IBM\OEMBIOS.CAT D7A77612
G:\xpdos\WXPOEM\LENOVO\OEMBIOS.CAT 5237B729
C:\WINXP\TEMP\oembios.cat 700A8481
C:\WINXP\TEMP\oembios.cat 74572CCF
C:\WINXP\TEMP\oembios.cat 162C7931
C:\WINXP\TEMP\oembios.cat 74572CCF
C:\WINXP\TEMP\oembios.cat D7A77612
C:\WINXP\TEMP\oembios.cat 7B06BD13
C:\WINXP\TEMP\oembios.cat 904CF15A
C:\WINXP\TEMP\oembios.cat 74572CCF
C:\WINXP\TEMP\oembios.cat 57E3E3DC
E:\OEM files~1\ACER\OEMBIOS.CAT 717B6EF3
C:\WINXP\TEMP\oembios.cat 7B06BD13


First, solve the following problem: how to restore the temporary directory C:\WINXP\TEMP\ to the original directory.

Then take it step by step. Thank you everyone. The old-fashioned mind is a bit not working well now.

[ Last edited by quya on 2008-7-9 at 09:42 PM ]
Floor18 26933062 Posted 2008-07-09 21:36
银牌会员 Posts 879 Credits 2,268
More and more don't know what you're going to do?
G:\IBM\oembios.cat D7A77612
C:\WINXP\TEMP\oembios.cat D7A77612
C:\WINXP\TEMP\oembios.cat D7A77612
C:\WINXP\TEMP\oembios.cat 90BBDCA0
G:\xpdos\WXPOEM\ACER\OEMBIOS.CAT 717B6EF3
C:\WINXP\TEMP\oembios.cat B20C65BF
G:\xpdos\WXPOEM\DELL\OEMBIOS.CAT B6F0EEFD
G:\xpdos\WXPOEM\HPQ\OEMBIOS.CAT CD4E1902
G:\xpdos\WXPOEM\IBM\OEMBIOS.CAT D7A77612
G:\xpdos\WXPOEM\LENOVO\OEMBIOS.CAT 5237B729
C:\WINXP\TEMP\oembios.cat 700A8481
C:\WINXP\TEMP\oembios.cat 74572CCF
C:\WINXP\TEMP\oembios.cat 162C7931
C:\WINXP\TEMP\oembios.cat 74572CCF
C:\WINXP\TEMP\oembios.cat D7A77612
Are these the contents of crc.txt?
If yes, does that mean the code on floor 7 doesn't work?
Floor19 quya Posted 2008-07-09 21:47
高级用户 Posts 172 Credits 558 From 江苏
越来越不知道你要干什么了?
G:\IBM\oembios.cat D7A77612
C:\WINXP\TEMP\oembios.cat D7A77612
C:\WINXP\TEMP\oembios.cat D7A77612
C:\WINXP\TEMP\oembios.cat 90BBDCA0
G:\xpdos\WXPOEM\ACE ...

I didn't test your code at the unit this afternoon, sorry. Just tried it just now, it's correct and very fast.

But can it solve the problem of restoring the original directory in the case of a compressed file? The problem I mentioned on floor 17.

Can you explain the meaning of the sentence "for /f "tokens=1* delims= " %%a in (1.txt) do set %%b=%%a"? %%b is the second token, which is "*" in "1*", how can it be assigned a value, I really don't understand.

Edit again, I kind of understand. In this way, many variables are generated. The variable name takes the second token, and the assigned value is the first one. I am worried that if my file is very long, will there be too many variable names and errors?

Because when I was a child, I knew that I should save variable names and release variables in time. The memory I had back then was extremely small, and I didn't dare to use too many variables.


[ Last edited by quya on 2008-7-9 at 10:02 PM ]
Floor20 26933062 Posted 2008-07-09 21:52
银牌会员 Posts 879 Credits 2,268
Don't understand
Is there a compressed file in 2.txt?
Can crc32.exe decompress it? And decompress it to the C:\WINXP\TEMP\ directory?
What was the original directory?
Floor21 quya Posted 2008-07-09 22:01
高级用户 Posts 172 Credits 558 From 江苏
Originally posted by 26933062 at 2008-7-9 09:52 PM:
Don't understand
Is there a compressed file in 2.txt?
Can crc32.exe decompress it? And decompress it to the C:\WINXP\TEMP\ directory?
What was the original directory?


Yes, the file with the extension .ca_ is a compressed file, which needs to be expanded and then verified. Please refer to the decompression code in my 17th floor, thank you.
Floor22 bat-zw Posted 2008-07-09 22:11
金牌会员 Posts 1,276 Credits 3,105
Did Laotu test my code for version 14? I added judgments and extraction for RAR files in it. You just need to modify it yourself.

[ Last edited by zw19750516 on 2008-7-9 at 10:20 PM ]
Floor23 quya Posted 2008-07-09 22:20
高级用户 Posts 172 Credits 558 From 江苏
Originally posted by zw19750516 at 2008-7-9 10:11 PM:
Did Lao Tu test my code for version 14? I added judgment and extraction for RAR files in it. You just need to change the suffix yourself.


Thank you for your code, but

1. The extraction is not WINRAR, of course I can change this.
2. The most critical thing is that you extracted it in the current directory, and the current directory may be read-only, so it must be extracted to a temporary directory.

Due to the problem of 2, how to get the original directory has become a problem.
Floor24 26933062 Posted 2008-07-09 22:33
银牌会员 Posts 879 Credits 2,268
Improve according to your code on floor 17, get the original directory and file name

As for the variable benefit you mentioned, I haven't encountered this problem yet.
I made a simple test, and no error phenomenon was found with 100,000 variable names. My physical memory is 128m
But if the content of your 1.txt is very long, if you use the previous code for+findstr, you will wait until your hair turns white...


[ Last edited by 26933062 on 2008-7-9 at 10:34 PM ]
Floor25 bat-zw Posted 2008-07-09 22:35
金牌会员 Posts 1,276 Credits 3,105
Oh, so troublesome, now this can solve your problem, right?


[ Last edited by zw19750516 on 2008-7-9 at 11:25 PM ]
Floor26 26933062 Posted 2008-07-09 22:59
银牌会员 Posts 879 Credits 2,268
I'm sorry, the 24th floor mentioned 100,000 variable names, but it wasn't fully tested. The actual test showed 40,000.
Floor27 quya Posted 2008-07-09 23:06
高级用户 Posts 172 Credits 558 From 江苏
The code on floors 24 and 25 has a missing % in %~fsi, but it's easy to fix.

The running result on floor 25 is not too ideal:

G:\IBM\oembios.cat D7A77612
G:\IBM\OEMBIOS.CA_ D7A77612
G:\WXPOEM\IBM\I386\OEMBIOS.CA_ D7A77612
G:\xpdos\I386\OEMBIOS.CA_ 90BBDCA0
G:\xpdos\WXPOEM\ACER\OEMBIOS.CAT 717B6EF3
G:\xpdos\WXPOEM\ASUS\OEMBIOS.CA_ B20C65BF
G:\xpdos\WXPOEM\DELL\OEMBIOS.CAT B6F0EEFD
G:\xpdos\WXPOEM\HPQ\OEMBIOS.CAT CD4E1902
G:\xpdos\WXPOEM\IBM\OEMBIOS.CAT D7A77612
G:\xpdos\WXPOEM\LENOVO\OEMBIOS.CAT 5237B729
F:\e\Backup\Tools\OEM 5 files\Acer\OEMBIOS.CA_ ??
F:\e\Backup\Tools\OEM 5 files\COMPAQ\OEMBIOS.CA_ ??
F:\e\Backup\Tools\OEM 5 files\HEDY\OEMBIOS.CA_ ??
F:\e\Backup\Tools\OEM 5 files\HP\OEMBIOS.CA_ ??
F:\e\Backup\Tools\OEM 5 files\IBM\OEMBIOS.CA_ ??
F:\e\Backup\Tools\OEM 5 files\Legend\OEMBIOS.CA_ ??
F:\e\Backup\Tools\OEM 5 files\SAMSUNG\OEMBIOS.CA_ ??
F:\e\Backup\Tools\OEM 5 files\Sony\OEMBIOS.CA_ ??
F:\FTP\Up\2003ent\OEMBIOS.CA_ 57E3E3DC
E:\OEM ??
E:\OEM files\LEGEND\OEMBIOS.CA_ ??


The running result on floor 24 is nearly perfect:

G:\IBM\oembios.cat D7A77612
G:\IBM\OEMBIOS.CA_ D7A77612
G:\WXPOEM\IBM\I386\OEMBIOS.CA_ D7A77612
G:\xpdos\I386\OEMBIOS.CA_ 90BBDCA0
G:\xpdos\WXPOEM\ACER\OEMBIOS.CAT 717B6EF3
G:\xpdos\WXPOEM\ASUS\OEMBIOS.CA_ B20C65BF
G:\xpdos\WXPOEM\DELL\OEMBIOS.CAT B6F0EEFD
G:\xpdos\WXPOEM\HPQ\OEMBIOS.CAT CD4E1902
G:\xpdos\WXPOEM\IBM\OEMBIOS.CAT D7A77612
G:\xpdos\WXPOEM\LENOVO\OEMBIOS.CAT 5237B729
F:\e\Backup\Tools\OEM 5 files\Acer\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5 files\COMPAQ\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5 files\HEDY\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5 files\HP\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5 files\IBM\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5 files\Legend\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5 files\SAMSUNG\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5 files\Sony\OEMBIOS.CA_ B20C65BF
F:\FTP\Up\2003ent\OEMBIOS.CA_ 57E3E3DC
E:\OEM ??
E:\OEM files\LEGEND\OEMBIOS.CA_ 57E3E3DC


But I can't figure out why the second-to-last result is like this!

I carefully checked the code, and there are no errors.

Testing with the following statement is also okay, really frustrating!



Everyone has worked hard!!! Thanks a million!!

[ Last edited by quya on 2008-7-9 at 11:08 PM ]
Floor28 bat-zw Posted 2008-07-09 23:09
金牌会员 Posts 1,276 Credits 3,105
If you don't generate the temporary crc.txt:


[ Last edited by zw19750516 on 2008-7-9 at 11:31 PM ]
Floor29 quya Posted 2008-07-09 23:16
高级用户 Posts 172 Credits 558 From 江苏
After carefully checking, there is still an issue.

F:\e\Backup\Tools\OEM 5文件\Acer\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5文件\COMPAQ\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5文件\HEDY\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5文件\HP\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5文件\IBM\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5文件\Legend\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5文件\SAMSUNG\OEMBIOS.CA_ B20C65BF
F:\e\Backup\Tools\OEM 5文件\Sony\OEMBIOS.CA_ B20C65BF


Here, all are the same.
Floor30 bat-zw Posted 2008-07-09 23:16
金牌会员 Posts 1,276 Credits 3,105
Originally posted by quya at 2008-7-9 23:06:
There is a missing % in the code %~fsi on floors 24 and 25, but it's easy to fix.

The running result on floor 25 is not too ideal:



The running result on floor 24 is close to perfect:



But I can't figure out why the second-to-last result is like this?!!
...

Is the 1.txt redundant?
Prev  1 2 3 4  Next
[ Contact the Union admin team - 中国DOS联盟 - Standard version ]
Sponsored by ifanr Inc | © 2001–2023