11

I'm looking for a file comparison utility specifically for .ini files, typically used as settings files.

There are plenty of file comparison tools (WinDiff, Beyond Compare, CompareIt, WinMerge, ...), but none of the tools I tried can handle .ini files very well.

A typical .ini file could look like this:

[Settings]
Setting1=abc
Setting2=xyz

The tool should match lines based on the string before the equal sign, then show differences in everything else after the equal sign. The order of lines within a section (sections are indicated by square brackets) does not matter and should be ignored.

I can't find any tool that can handle this. Typically existing tools will show differences in the beginning of the line before the equal sign (if most of the text after the equal sign matches), they will struggle with re-ordered lines (either show it all as changed or match some lines and show the remaining as deleted in one place and then added in another). I even found some tools where matching text can be restricted e.g. using regular expressions, but these simply ignore the remainder of the line and I can't match lines up based on one pattern (i.e. everything before the equal sign) and then compare them based on another (everything after the equal sign).

4
  • Now that I've read your question, I really don't understand what you want ... perhaps you can show what you WANT as well as what you have. regexes and diff should be able to handle what you want to do. Jun 18, 2009 at 17:45
  • You should rename your post .... Is there a tool to compare values in .ini files? Jun 18, 2009 at 17:50
  • 1
    For OS/2: os2world.com/goran/initools.htm ;-)
    – splattne
    Jun 18, 2009 at 19:09
  • Thanks Joseph, good point, I have edited the title. splattne - initools sounds like it would be perfect, shame I'm using Windows.
    – ssollinger
    Jun 19, 2009 at 9:39

6 Answers 6

7

Beyond Compare has a sorted INI rule you can download.

2
4

Yes, I know this is an ancient question, but I'd like to suggest a tool I wrote:

dzIniFileFormatter which is available from SourceForge

2

I've often just sorted the files before comparing. It won't help if you have something like

[foo]
bar1=xyz
bar2=abc
[foo2]
bar1=lky

but assuming that your keys are unique (and can therefore be matched to a section), it often works in a pinch.

2
  • This sometimes helps, however as you said it doesn't work if there are several sections, it also fails often if there are several lines missing in one of the files (most tools then start trying to match the wrong lines up).
    – ssollinger
    Jun 19, 2009 at 9:43
  • true; I'm not recommending it as an ideal, but in a pinch, it can often help
    – Mikeage
    Jun 19, 2009 at 16:44
2

Try vimdiff. Here's an example with .ini files.

3
  • MY EYES! .Xdefaults! Change them! Jun 18, 2009 at 17:47
  • 1
    Yes, it's very ugly, sorry. But I don't think it has nothing to do with .Xdefaults as this is console. I'll look in the vim documentation to change these colors :).
    – chmeee
    Jun 18, 2009 at 17:49
  • 1
    in case anyone else is interested - vimdiff is available via vim.org. VimDiff is ok, but it fails when lines are swapped and then the value is a closer match then the string before the equal sign. In this case VimDiff will show the difference in the part before the equal sign, which is not what I want.
    – ssollinger
    Jun 19, 2009 at 13:23
2

This service should help you. Compares more than two configuration files http://inicompare.io/

0

I've always liked Winmerge, very customizable.

3
  • WinMerge is great but doesn't deal with settings files (.ini files) very well. It is better then some others (like WinDiff), but my question was for a tool that specifically compares the values in .ini files. WinMerge can't do this.
    – ssollinger
    Jun 19, 2009 at 9:44
  • 1
    Winmerge has a setting for comparing blocks of text that have moved and are similar. I use it for comparing web.config files, but I guess those are little more organized than ini files.
    – Dave
    Jun 20, 2009 at 11:36
  • I use WinMerge and do a regex substitution on each file to remove the numbers before comparing ([0-9]+= to =). But I have always to discard the changed files. I'm also looking for a better solution.
    – djeidot
    Nov 10, 2010 at 13:30

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