Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare two files and make changes so they are indentical

Status
Not open for further replies.

dsnyrs

Programmer
May 26, 2011
4
US
Hello All,

I have two files, one is old where "some" data from this file needs to be overwritten into the second file. The files are actually .reg files. In these files, there are about 30 keys that are defined but only about 10 keys need to be updated. An example of the two files are shown below.


file(old).reg
***********************************************

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOMETHING\PERM\PhoneNumber]
@="1234567"

[HKEY_CURRENT_USER\SOMETHING\PERM\ClientCode]
@="B01"

[HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\....]
"Account Name"="blah,blah,blah.com"
"ServerName"="PCCCCP"

Etc.
Etc.






file(new).reg
***********************************************

Windows Registry Editor Version 5.00

[HKEY_CURRENT_USER\SOMETHING\PERM\PhoneNumber]
@="XXXXXXX"

[HKEY_CURRENT_USER\SOMETHING\PERM\ClientCode]
@="XXX"

[HKEY_CURRENT_USER\SOFTWARE\MICROSOFT\....]
"Account Name"="blah,blah,blah.com"
"ServerName"="XXXXXX"

Etc.
Etc.
********************************************


Can anyone assist? Is this easier with batch or with vbscript? I am learning both at this time and perhaps this request is a bit over my head. All I'm looking for is code snippets.

Thanks in advance!!!!
 
I've attempted this before and soon realized that manually merging the files is faster and easier.

Logically, though, you would want to store each file in an array and merge the two arrays. The difficulty comes when trying to program content relationships.

Just my two cents

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Thanks jges,

I need to find code though. I have make these changes for over 400 clients so automation is in my best interest. I will definately use DiffMerge for other things. Looks like a great tool.

:)
 
Are you always interested in the same 10 keys? And you always wanto to take this information from the old file and overwrite it into the new (as opposed to comparing the info from each and deciding which to keep)?

By the sounds of it, you basically have a template file and want to populate it with 10 pieces of information pulled from the existing file (400 times).

Is this correct? If so, this makes the task much easier than my initial understanding.
 
Why can't you just create a new reg file with just the 10 specific keys?

The clients are already set up and running?

Otherwise as long as they are key value pairs you are going to have to create a while loop to iterate through the existing file. Once you find a key that you care about, drop to the next line and replace the old value. Do that till you get to the end of the file?

Lodlaiden

A lack of experience doesn't prevent you from doing a good job.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top