6

I have two INI files, and I want see the differences between then (which keys have different values, and which keys one has that the other don't), so...

How-to compare two (or more) INI files?

1

11 Answers 11

7

Here is an answer from serverfault.

https://serverfault.com/questions/28194/is-there-a-tool-to-compare-values-in-ini-files

5

Try IniCompare

alt text

Or have a look at this list of Ini editors/compare tools, though a differencing tool would be the easiest probably

3
3

You may use a comparison tool for that, like Winmerge, an open source and free differencing tool for Windows. It shows the two files side-by-side, colormarking the differences.

Supports Microsoft Windows 98/2000/XP/2003/Vista/7.

2

I've been using Beyond Compare by Scootersoftware for over 10 years now. http://www.scootersoftware.com/

1

Use file compare command-line utility (in any windows) from the command prompt (enter cmd intor start/run dialog)

fc inifile1.ini inifile2.ini 

The result will be typed aftewards. If you would like to review the results

fc inifile1.ini inifile2.ini > results.txt

After the latter you will see the report in the file results.txt

2
  • +1 for coming with a solution which doesn't require additional software.
    – TFM
    Aug 24, 2009 at 13:07
  • 4
    -1 for comming with a solution which doesn't meet the requirements Aug 24, 2009 at 13:16
1

I found a lovelly windows freeware utility called ExamDiff the other day that will do exactly what you want, is user friendly and free. It will even do directory comparisons if you pay for the 'pro' version.

1
  • Only the paid version has plugins, which you need for ini sorting.
    – dangph
    Apr 13, 2010 at 3:15
1

I'm using this service http://inicompare.io/

Compares more than two.

1
  • Please quote the essential parts of the answer from the reference link, as the answer can become invalid if the linked page changes or the target site is unreachable/permanently offline.
    – DavidPostill
    Nov 7, 2014 at 6:44
1

For the reason I didnt found what I was looking for, here my quick and dirty python solution, maybe it helps someone:

import configparser as cp

f1 = "org.ini"
f2 = "new.ini"

config1 = cp.ConfigParser()
config2 = cp.ConfigParser()
config1.read(f1)
config2.read(f2)

for section in config1.sections():
    if section not in config2.sections():
        print(section, "NOT in 2")
    else:
        for key in config1[section]:
            if key not in config2[section]:
                print("[miss] section", section, "key", key, "not in new")
            else:
                if config1[section].get(key).split(";")[0].strip() != config2[section].get(key).split(";")[0].strip():
                    print("[chang] section", section, "key", key, config1[section].get(key).split(";")[0].strip(),
                          "org != new", config2[section].get(key).split(";")[0].strip())
for section in config2.sections():
    if section not in config1.sections():
        print(section, "NOT in 1")
    else:
        for key in config2[section]:
            if key not in config1[section]:
                print("[miss] section", section, "key", key, "not in org")
1

To compare 3 files, you can use a VimDiff, e.g.

vimdiff file1.ini file2.ini file3.ini

For GUI tools, check:

0

I actually wrote a CLI app to deal with this problem when I was dealing with it in the workplace, and my employer was kind enough to let me open source it:

https://github.com/Comcast/compare-ini-files

This will compare 2 or more ini files, and report back on values that are different, and stanzas that are missing.

0

This is a newer version of this http://winmerge.org/source-code/ which someone has posted here in this thread.

WinMerge v2

https://github.com/WinMerge/winmerge-v2/releases

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .