Jump to content

How to merge two text files?


Recommended Posts

Sorry it didn't work for you. It's been a while since I've run Win2K, after running it for ~10 years. The above standalone script has only been tested, by me, on XP and Win7 x32. I didn't think about it possibly having a problem on Win2K, though I'm not sure why it should. I found it in Strel's SNMSynth program, http://www.msfn.org/board/topic/127790-silent-net-maker-synthesized-20100118-w2kxp2k3-x86/, which I believe is supposed to run on Win2K. So I'm confused.

The original code snippet is this:

:FILEVERSCRIPT

ECHO>>TMP\FILEVER.VBS Option Explicit

ECHO>>TMP\FILEVER.VBS Dim FSystem

ECHO>>TMP\FILEVER.VBS Set FSystem = CreateObject^("Scripting.FileSystemObject"^)

ECHO>>TMP\FILEVER.VBS WScript.Echo FSystem.GetFileVersion^(WScript.Arguments^(0^)^)

ECHO>>TMP\FILEVER.VBS Set FSystem = Nothing

GOTO :EOF

Cheers and Regards

Edited by bphlpt
Link to comment
Share on other sites


I don't know if it's me doing something wrong or the script is wrong but I tested it on 3 different systems (w2k adv srv, w2k pro, xp pro) and always got errors... :/ On the other hand, I've been using SNMSynch with no problems here.

Edited by tomasz86
Link to comment
Share on other sites

Codeboxes are adding trailing spaces, of late. I believe jaclaz was the first to report it. Check you script for trailing spaces and be sure to remove them. They can be a PITA because they break otherwise working programs sometimes, but you don't usually see them, unless you're looking for them. This is a longshot, by maybe it'll solve your issue.

Link to comment
Share on other sites

  • 2 weeks later...

Actually there was something wrong with my system, not with the script :P I reinstalled everything any now FILEVER.VBS seems to work as it is. I also found a use for dencorso's yanklines script to remove duplicates from update.ver.

The real problem is update.inf. What has to be done is to merge everything according to headings in each update.inf file and then remove duplicates but only under the same heading. I don't know how to do it yet :lol: If I use yanklines for the whole update.inf, all duplicates are indeed removed but some identical lines must exist under different headings - yanklines removes all of them :(

At this moment I just use Kdiff3 to merge update.infs as it takes less time than thinking how to prepare a script to do it automatically :lol:

Edited by tomasz86
Link to comment
Share on other sites

Yes, I downloaded and checked all tools mentioned in this topic but I don't really know how I could use FEDIT when merging these files :/

Here is an example (fragments only as full update.inf files are very long)

Full update.inf files here: http://www.mediafire.com/file/y4nklybw4mbuog1/update.infs_to_merge.7z

1.inf

[Version]

Signature = "$Windows NT$"
LanguageType = %LangTypeValue%
NtBuildToUpdate = 2195
NtMajorVersionToUpdate = 5
NtMinorVersionToUpdate = 0
MaxNtBuildToUpdate = 2195
MaxNtMajorVersionToUpdate = 5
MaxNtMinorVersionToUpdate = 0
MinNtServicePackVersion = 768
MaxNtServicePackVersion = 1024
ThisServicePackVersion = 1280
CatalogFile = %SP_SHORT_TITLE%.cat

[System32.Files]

acctres.dll
adsiis.dll
adsldp.dll,,,8
adsldpc.dll,,,8

[Cache.Files]

acctres.dll
adsiis.dll
adsldp.dll,,,8
adsldpc.dll,,,8

[Strings]

CMAKRegkey="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Cmak.exe"
ProxyRegKey="SYSTEM\CurrentControlSet\Services\WSPSrv\Parameters"
IeRegKey="Software\Microsoft\Windows\CurrentVersion\App Paths\iexplore.exe"
ResKitPathKey="SOFTWARE\Microsoft\ResKit\NameSpace\Windows 2000 Resource Kit"
HyperRegKey="SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\hypertrm.exe"
EudcRegKey="Software\Microsoft\Windows\CurrentVersion\App Paths\eudcedit.exe"
AdmtRegKey="SOFTWARE\Microsoft\ADMT"
TsclientRegKey="SOFTWARE\Classes\conman.exe\DefaultIcon"
BUILDTIMESTAMP =20050809.32623
HelpLink = "http://support.microsoft.com?kbid=891861"
URLInfoAbout = http://support.microsoft.com
SP_KB_NUMBER = "KB891861"
SERVICE_PACK_NUMBER = 5

2.inf

[Version]

Signature = "$Windows NT$"
LanguageType = %LangTypeValue%
NtBuildToUpdate = 2195
NtMajorVersionToUpdate = 5
NtMinorVersionToUpdate = 0
MaxNtBuildToUpdate = 2195
MaxNtMajorVersionToUpdate = 5
MaxNtMinorVersionToUpdate = 0
MinNtServicePackVersion = 1024
MaxNtServicePackVersion = 1024
ThisServicePackVersion = 1280
CatalogFile = %SP_SHORT_TITLE%.cat

[System32.Files]

adsmsext.dll,,,8
BASESRV.DLL,,,8
browser.dll,,,8
browseui.dll
cabinet.dll

[Cache.Files]

adsmsext.dll,,,8
BASESRV.DLL,,,8
browser.dll,,,8
browseui.dll
cabinet.dll

[Strings]

CMAKRegkey=SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Cmak.exe
ProxyRegKey=SYSTEM\CurrentControlSet\Services\WSPSrv\Parameters
IeRegKey=Software\Microsoft\Windows\CurrentVersion\App Paths\iexplore.exe
ResKitPathKey=SOFTWARE\Microsoft\ResKit\NameSpace\Windows 2000 Resource Kit
HyperRegKey=SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\hypertrm.exe
EudcRegKey=Software\Microsoft\Windows\CurrentVersion\App Paths\eudcedit.exe
AdmtRegKey=SOFTWARE\Microsoft\ADMT
TsclientRegKey=SOFTWARE\Classes\conman.exe\DefaultIcon
BUILDTIMESTAMP =20080110.104158
HelpLink = "http://support.microsoft.com?kbid=942831"
URLInfoAbout = http://support.microsoft.com
LangTypeValue = 9

Edited by tomasz86
Link to comment
Share on other sites

You are right these particular .inf files need some "special treatment".

There are lots of "beautifying" uneeded spaces that create havoc! :ph34r:

Additionally you simply cannt write properly with FEDIT something that is ALREADY between double quotes (like "$Windows NT$").

I'll do some tests with batch and a bunch of utilities and let you know.

jaclaz

Link to comment
Share on other sites

I'll do some tests with batch and a bunch of utilities and let you know.

Did some tests, and the matter is a bit complex, but now I can say it can be done, though not with "ini related" tools, since the .inf seem like having a "queer" set of rules.

Don't expect anything too soon, but I have great expectations from a new approach I just took ... :)

jaclaz

Link to comment
Share on other sites

Thank you very much for your interest.

Don't worry and just take your time :) It's better not to be too hasty when doing these things (as I experienced myself when doing some of my projects...).

Link to comment
Share on other sites

  • 2 weeks later...

NOT the intended "final" result, ONLY "intermediate steps".

Find attached three batches.

  1. splitinf.cmd - to split an existing .inf (run it with one parameter, the original .inf)
  2. join_inf.cmd - to join the split parts created by the above (run it with one parameter, the SPLIT_ directory)
  3. beautify.cmd - to make the result more readable and reset some changes I have to do to the Split parts to process them easily in batch

gsar is needed:

http://home.online.no/~tjaberg/

Basically:

  • create a directory (please NO spaces in paths or filenames) like C:\INFTEST
  • put in it the batches, gsar.exe and the (basis)Windows2000-KB891861-v2-x86-ENU.EXE.inf (please rename it to something manageable, like "base2K.inf"), never use in filenames characters that are parsed by the command line, like "(", ")", "&" "|" and interpreted like commands or are however part of syntax or need to be escaped normally, even if allowed on the filesystem, see here:
    http://en.wikipedia.org/wiki/Filename
    (please note how right now the batches do use "[" and "]" so may be not good on a FAT filesystem, please use them on a NTFS one)
  • open a command prompt and navigate to the directory you made:
    CD /D C:\INFTEST


  • run:
    splitinf.cmd base2K.inf


    join_inf.cmd SPLIT_base2K


    beautify.cmd JOINED_base2K.inf


  • the "end result", i.e. BEAUTY_JOINED_base2K.inf should be comparable with the original base2K.inf and be a "fully" working .inf file

If not, post which problems there are.

Once we get these steps working successfully, we will talk about the actual merging of the "base" with another "split" file....

Also, I have noticed that in some of the "example files" there are many "empty" sections, are they actually *needed* (right now they are mantained as they are)?

Please note how the above are early, preliminary tests and the actual .cmd's need to be cleaned and polished a lot (and quite a bit of "error controls" need to be added to them).

jaclaz

split_inf.zip

Edited by jaclaz
Link to comment
Share on other sites

Wow :w00t:

I've just done four tests:

1. A simple update.inf from a single W2K update - w2k_KB838989.inf

No problems. The only difference was in the number of spaces under [Version].

TQ7Ibs.png

2. Update.inf from Update Rollup 1 for W2K - w2k_KB891861-v2.inf

There are two problems:

- "==" changes to "§#§"

- "&" changes to "§##§"

UQdX6s.png wI6ALs.png

3. Update.inf from Update Rollup 2 for W2K - w2k_KB891861-UR2-v2.inf

First of all, I got this when doing splitinf.cmd

pYEdrs.png CPmpes.png

It continued after that. No problems occured during join_inf.cmd and beautify.cmd.

In the final file:

- "ECHO is off." was inserted several times in many different places.

paNXBs.png

- one line is missing (?)

K8dSqs.png

- "mod by jaclaz" at the end of the file

Sfr1cs.png

4. Update.inf from SP4 for W2K - w2k_SP4.inf

- In SP4's update.inf there is [sourceDisksFiles] twice (each of them is different). One of them was changed.

9txV7s.png

As for the empty sections, they are not needed when empty and needed when not empty. There are some sections that are almost never used but there can be just one update that uses such a section. I think it's better to have them all ;)

Edited by tomasz86
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...