![]() |
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-23 14:52 |
47,812 topics / 349,917 posts / today 0 new / 48,273 members |
| DOS批处理 & 脚本技术(批处理室) » Can batch processing achieve such a function??? |
| Printable Version 2,030 / 8 |
| Floor1 酷星河 | Posted 2005-01-27 00:00 |
| 初级用户 Posts 7 Credits 134 | |
|
Compare d:\123\1.txt and \\server\123\1.txt. If the contents are the same, run d:\123\1.exe; if different, run \\server\123\2.exe. If possible, please tell me how to implement it. Thanks
|
|
| Floor2 Climbing | Posted 2005-01-28 00:00 |
| 铂金会员 Posts 2,753 Credits 6,962 From 河北保定 | |
|
@echo off
fc d:\123\1.txt \\server\123\1.txt > nul if errorlevel 1 goto _runserver if errorlevel 0 goto _runlocal goto _quit :_runserver \\server\123\2.exe goto _quit :_runlocal d:\123\1.exe :_quitIn the above example, fc is used to compare files. Of course, you can use tools like CRC or md5sum to calculate the checksum values of two files to compare whether the files are the same. Also, remind you to write a good post title. |
|
| Floor3 JonePeng | Posted 2005-01-29 00:00 |
| 金牌会员 Posts 1,883 Credits 4,562 From 广东广州 | |
|
Brother Climbing: I found that under Win98, the return value of FC is 0 whether the two files are the same or not, which is a wrong judgment, isn't it?
|
|
| Floor4 crshen | Posted 2005-01-29 00:00 |
| 中级用户 Posts 126 Credits 447 | |
|
The narrow sense of batch processing refers to a command sequence composed of DOS internal commands (such as copy, dir) and batch processing commands such as for, goto. The broad sense of batch processing refers to calling multiple external files according to certain requirements, and as long as the operations supported by external commands are concerned, batch processing can be realized. In the above example, it is completely possible to write a program by yourself, return different values according to whether two files are the same or not, and then use if errorlevel to handle it.
|
|
| Floor5 JonePeng | Posted 2005-01-29 00:00 |
| 金牌会员 Posts 1,883 Credits 4,562 From 广东广州 | |
|
Haha, batch processing also has narrow and broad senses. I always thought there were only simple and complex ones. crshen: Do you mean to write a more perfect FC? I support you! Shake hands first...
|
|
| Floor6 crshen | Posted 2005-02-01 00:00 |
| 中级用户 Posts 126 Credits 447 | |
The following is a statement from JonePeng on 2005-1-29 22:46:53: I took some time today to write a small program specifically for comparing text files. The usage is: fc.exe file1 file2 ; Compare file1 and file2 byte by byte fc.exe file1 file2 /blank ; When comparing the two files, ignore all spaces, for example, "abcd " and "a bc d" are the same. After comparison, return 1 indicating that the two files are the same, return 0 indicating differences, and return 2 indicating an error occurred during program operation. There are test files inside. Open the attachment |
|
| Floor7 JonePeng | Posted 2005-02-01 00:00 |
| 金牌会员 Posts 1,883 Credits 4,562 From 广东广州 | |
|
Great! And it can compare files larger than 64K. I wonder which compiler was used?
P.S.: The last word in the returned message "Two files are NOT eaqule!" is incorrect; it should be "equal". |
|
| Floor8 crshen | Posted 2005-02-01 00:00 |
| 中级用户 Posts 126 Credits 447 | |
|
Thanks JonePeng, the errors have been corrected and re-uploaded. I used Turbo C 2.0 for compilation. I feel that the binary comparison function is generally not used in batch processing, so I didn't add it to reduce the program size. I wonder if the expert has any other suggestions?
|
|
| Floor9 willsort | Posted 2005-02-01 00:00 |
| 元老会员 Posts 1,512 Credits 4,432 | |
|
Re crshen:
Just downloaded, not tested yet, let's give a few functional suggestions first, for reference only. Binary comparison is still widely applied in batch processing, such as comparing two disk image files, comparing the same pictures among multiple pictures. The following suggestions are for binary comparison. 1. Add comparison of multiple files, for example, compare all similar pictures among a large number of pictures; 2. Add file similarity index, for example, two files have an 80% similarity rate; 3. Add file update comparison, for example, which of the two WORD documents is more up-to-date; 4. Improve file comparison speed, select a non-byte-by-byte comparison algorithm, for example, generate MD5 respectively and then compare. Wish you success! |
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |