|
quan_zhou
初级用户
 
积分 190
发帖 40
注册 2005-3-17
状态 离线
|
『楼 主』:
将一文本文件与N个文本文件作比较,若与某文件内容相同则运
使用 LLM 解释/回答一下
大家好!请教各前辈我想在Dos 下编个批处理,将一个文本文件与N个文本文件作比较,若与某文件内容相同则运行一个与该文本文件相同文件名的批处理文件。
例:若X.txt与1.txt 内容相同则运行1.bat;
若X.txt与2.txt内容相同则运行2.bat。
请问该怎编?
Hello everyone! I would like to ask the predecessors. I want to compile a batch file under Dos to compare a text file with N text files. If it is the same as a certain file content, run a batch file with the same file name as the text file.
For example: if X.txt is the same as 1.txt content, then run 1.bat;
if X.txt is the same as 2.txt content, then run 2.bat.
May I ask how to compile this?
|
|
2005-3-17 00:00 |
|
|
chenhui530
高级用户
   
积分 772
发帖 273
注册 2004-10-23
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
楼主你应该把要执行的批处理所对应的TXT文件列出来啊!不然谁知道有多少啊!是哪些啊
所以我就写了全面看能满足你的要求吗?
要比较的和比较的文件以及BAT文件都得放在一个目录下for %%a in (*.txt) do for %%b in (*.txt) do fc %%a %%b | find "找不到相异处" && %%~na.bat
The LZ you should list the TXT files corresponding to the batch processing to be executed! Otherwise, who knows how many there are! Which ones are they? So I wrote it comprehensively. Can it meet your requirements? The files to be compared, the files to be compared, and the BAT files all need to be placed in the same directory. for %%a in (*.txt) do for %%b in (*.txt) do fc %%a %%b | find "No differences were found" && %%~na.bat
|

http://www.msfans.net/bbs/ |
|
2005-3-18 00:00 |
|
|
quan_zhou
初级用户
 
积分 190
发帖 40
注册 2005-3-17
状态 离线
|
『第 3 楼』:
多谢 chenhui530 不好意思我写得不够清楚。
使用 LLM 解释/回答一下
我想写个批处理,DOS 7.1下将C:\X.txt 与D:\1.txt至99.txt 比较。其中1.txt至99.txt只有一个是与X.txt内容是相同的。
TEST.bat、1.txt至99.txt、1.bat 至99.bat 都在D:\
若X.TXT 与1.TXT内容相同则运行 1.BAT。
若X.TXT 与2.TXT内容相同则运行 2.BAT。
若X.TXT 与88.TXT内容相同则运行 88.BAT。
若X.TXT 与99.TXT内容相同则运行 99.BAT。
我写的TEST.bat 的内容
FOR %%C IN (*.TXT|) DO FC %%C C:\X.TXT
----------------------------------------------------------------
TEST.bat对比了那些文件,但要怎能才能运行那个对应的BAT呢? 请指教
I want to write a batch script. Under DOS 7.1, compare C:\X.txt with D:\1.txt to 99.txt. Among them, only one of 1.txt to 99.txt has the same content as X.txt.
TEST.bat, 1.txt to 99.txt, 1.bat to 99.bat are all in D:\
If the content of X.TXT is the same as that of 1.TXT, then run 1.BAT.
If the content of X.TXT is the same as that of 2.TXT, then run 2.BAT.
If the content of X.TXT is the same as that of 88.TXT, then run 88.BAT.
If the content of X.TXT is the same as that of 99.TXT, then run 99.BAT.
The content of the TEST.bat I wrote
FOR %%C IN (*.TXT|) DO FC %%C C:\X.TXT
----------------------------------------------------------------
TEST.bat has compared those files, but how can I run the corresponding BAT? Please give me some advice
|
|
2005-3-18 00:00 |
|
|
chenhui530
高级用户
   
积分 772
发帖 273
注册 2004-10-23
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
我没有98的FC你传个上来我好给你写出批处理来
I don't have the FC of 98. You upload one so that I can write a batch script for you
|

http://www.msfans.net/bbs/ |
|
2005-3-19 00:00 |
|
|
quan_zhou
初级用户
 
积分 190
发帖 40
注册 2005-3-17
状态 离线
|
『第 5 楼』:
再次谢谢chebhui530的关注
使用 LLM 解释/回答一下
我是在DOS 7.1下使用的,这次上传的也是。
我这样试了一下也不行
----------------test.bat-----------
fc c:\x.txt d:\1.txt
if errorlevel 1 goto 2
if errorlevel 0 call 1.bat
:2
fc c:\x.txt d:\2.txt
if errorlevel 1 goto 3
if errorlevel 0 call 2.bat
:3
--------------------------------------
可是不管那两个文件是相同或有差异都是返回“0”。
I am using under DOS 7.1, and this upload is also.
I tried like this and it didn't work.
----------------test.bat-----------
fc c:\x.txt d:\1.txt
if errorlevel 1 goto 2
if errorlevel 0 call 1.bat
:2
fc c:\x.txt d:\2.txt
if errorlevel 1 goto 3
if errorlevel 0 call 2.bat
:3
--------------------------------------
But no matter whether the two files are the same or different, it returns "0".
|
|
2005-3-19 00:00 |
|
|
chenhui530
高级用户
   
积分 772
发帖 273
注册 2004-10-23
状态 离线
|
『第 6 楼』:
使用 LLM 解释/回答一下
以下是引用quan_zhou在2005-3-19 14:08:43的发言:
我是在DOS 7.1下使用的,这次上传的也是。
我这样试了一下也不行
----------------test.bat-----------
fc c:\x.txt d:\1.txt
if errorlevel 1 goto 2
if errorlevel 0 call 1.bat
:2
fc c:\x.txt d:\2.txt
if errorlevel 1 goto 3
if errorlevel 0 call 2.bat
:3
--------------------------------------
可是不管那两个文件是相同或有差异都是返回“0”。
应该是这样的
if not errorlevel 1 echo find
The following is the statement from quan_zhou on 2005-3-19 14:08:43:
I am using it under DOS 7.1, and this upload is also.
I tried like this and it didn't work
----------------test.bat-----------
fc c:\x.txt d:\1.txt
if errorlevel 1 goto 2
if errorlevel 0 call 1.bat
:2
fc c:\x.txt d:\2.txt
if errorlevel 1 goto 3
if errorlevel 0 call 2.bat
:3
--------------------------------------
But no matter whether the two files are the same or different, it returns "0".
It should be like this
if not errorlevel 1 echo find
|

http://www.msfans.net/bbs/ |
|
2005-3-19 00:00 |
|
|
chenhui530
高级用户
   
积分 772
发帖 273
注册 2004-10-23
状态 离线
|
『第 7 楼』:
使用 LLM 解释/回答一下
你这样的批处理是不现实的!为了从100个文件中比较一个写了那么多的命令不好你把98的FC传给我我给你写一个批处理不要多长的代码就可以搞定
Your such batch processing is unrealistic! To compare from 100 files, writing so many commands is not good. You pass me the FC of 98, and I'll write a batch processing which can be done with not much code.
|

http://www.msfans.net/bbs/ |
|
2005-3-19 00:00 |
|
|
quan_zhou
初级用户
 
积分 190
发帖 40
注册 2005-3-17
状态 离线
|
|
2005-3-19 00:00 |
|
|
chenhui530
高级用户
   
积分 772
发帖 273
注册 2004-10-23
状态 离线
|
『第 9 楼』:
使用 LLM 解释/回答一下
我在DOS7。1下试了FC。EXE怎么没返回值啊?
也许是我这有问题我把代码提供给你你自己改一点点就行了需要个第三方工具STRINGS有什么问题再反映因为我无法测试!STRINGS.com可以在软件站下载:kaishi
strings a=add %b%,1
if not exist %a% fc x.txt %a%.txt>fc.txt
find "相同时FC的代码" fc.txt
if not errorlevel 1 %a%.bat
strings b=add %a%,1
if %b%==101 goto end
goto kaishi:end
I tried FC.EXE under DOS 7.1 but there was no return value. Maybe there's a problem on my side. I'll provide the code for you to make a little change. Need a third - party tool STRINGS. If there's any problem, reflect it because I can't test! STRINGS.com can be downloaded from the software station: kaishi
strings a=add %b%,1
if not exist %a% fc x.txt %a%.txt>fc.txt
find "When the same FC code" fc.txt
if not errorlevel 1 %a%.bat
strings b=add %a%,1
if %b%==101 goto end
goto kaishi:end
|

http://www.msfans.net/bbs/ |
|
2005-3-20 00:00 |
|
|
小石头
初级用户
 
积分 165
发帖 28
注册 2004-8-9
状态 离线
|
『第 10 楼』:
使用 LLM 解释/回答一下
DOS 7.1下的fc是不能用于批处理中的文件比较的,所以在这里必须引入第三方工具,我在网上找到了两个:filecomp和gscom。另外,使用md5sum或者fsum之类的工具,通过计算文件的md5或者crc32值也可以比较文件是否相同。另外,DOS 7.1下的for命令不支持等差序列的数字变量的产生,所以必须使用类似楼上的strings或者varset之类的第三方程序用来产生数字的顺序增加操作。基本上,楼上的程序只要换一下文件比较工具就可以了。
The fc under DOS 7.1 cannot be used for file comparison in batch processing, so third - party tools must be introduced here. I found two on the Internet: filecomp and gscom. In addition, tools like md5sum or fsum can also be used to compare whether files are the same by calculating the md5 or crc32 values. Also, the for command under DOS 7.1 does not support the generation of digital variables in arithmetic sequences, so third - party programs like strings or varset above must be used to perform the operation of sequentially increasing numbers. Basically, the program above can be used by just changing the file comparison tool.
|
|
2005-3-20 00:00 |
|
|
quan_zhou
初级用户
 
积分 190
发帖 40
注册 2005-3-17
状态 离线
|
『第 11 楼』:
谢谢大家的关注!能否把FC.EXE 改成有返回值?
使用 LLM 解释/回答一下
谢谢大家的帮助!
我在DOS 7.1 下 不管两文件相同还是有差异都是返回0
请问我们能否更改FC.exe的返回值?
Thanks for everyone's help!
I under DOS 7.1, no matter whether two files are the same or different, it returns 0.
Can we change the return value of FC.exe?
|
|
2005-3-21 00:00 |
|
|
chenhui530
高级用户
   
积分 772
发帖 273
注册 2004-10-23
状态 离线
|
『第 12 楼』:
使用 LLM 解释/回答一下
在DOS 7.1下好像FC没返回值
It seems that under DOS 7.1, FC has no return value
|

http://www.msfans.net/bbs/ |
|
2005-3-21 00:00 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 13 楼』:
使用 LLM 解释/回答一下
楼上的“小石头”(也就是我的马甲)已经讲过了,就是因为DOS 7.1下的fc没有返回值,所以无法用于判断文件是否相同,所以我提供了另两个用于DOS下的文件比较工具,这两个工具都是有返回值的。gscmp的下载地址:http://www.programmersheaven.com/d/click.aspx?ID=F19947&URL=http%3A%2F%2Fwww.goldsealstudios.com%2Fcgi-bin%2Fdownload.pl%3fdl=gscmp.zipfilecomp的下载地址:http://www.programmersheaven.com/d/click.aspx?ID=F3062在本帖的环境中,我推荐使用gscmp,因为简单易用,而filecomp虽然功能更强,但使用起来也比较麻烦。
The user above, "Little Stone" (which is my alternate account), has already explained that it's because fc under DOS 7.1 has no return value, so it can't be used to judge whether files are the same. Therefore, I provided two other file comparison tools for DOS, and both of these tools have return values. The download address for gscmp: http://www.programmersheaven.com/d/click.aspx?ID=F19947&URL=http%3A%2F%2Fwww.goldsealstudios.com%2Fcgi-bin%2Fdownload.pl%3fdl=gscmp.zip The download address for filecomp: http://www.programmersheaven.com/d/click.aspx?ID=F3062 In the environment of this thread, I recommend using gscmp because it's simple and easy to use, while filecomp has more functions but is more troublesome to use.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2005-3-21 00:00 |
|
|
quan_zhou
初级用户
 
积分 190
发帖 40
注册 2005-3-17
状态 离线
|
『第 14 楼』:
使用 LLM 解释/回答一下
非常多谢大家的帮助!
我下了gscmp 在DOS7.1不能正常运行,提示该程序不能在DOS 方式下运行。
XP 的DOS 能正常运行。
Climbing 能否再次麻烦你给个能在DOS 7.1下运行的,谢谢!
Thanks a lot for everyone's help!
I downloaded gscmp and it doesn't run normally in DOS 7.1, prompting that this program can't run in DOS mode.
It can run normally in XP's DOS.
Climbing, could you please trouble to give another one that can run in DOS 7.1 again, thanks!
|
|
2005-3-21 00:00 |
|
|
Climbing
铂金会员
       网络独行侠
积分 6962
发帖 2753
注册 2003-4-16 来自 河北保定
状态 离线
|
『第 15 楼』:
使用 LLM 解释/回答一下
那就使用filecomp吧,我因为没有在DOS 7.1下试,从说明上看,这两个程序都是用于纯DOS环境的,所以想当然的以为都可以用于DOS 7.1环境,我觉得filecomp应该是没有问题的。
Then use filecomp. I didn't test it under DOS 7.1. From the description, both programs are for the pure DOS environment, so I thought they could both be used in the DOS 7.1 environment. I think filecomp should be okay.
|

偶只喜欢回答那些标题和描述都很清晰的帖子!
如想解决问题,请认真学习“这个帖子”和“这个帖子”并努力遵守,如果可能,请告诉更多的人!
|
|
2005-3-21 00:00 |
|