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).

ssollinger
  • 233
  • 1
  • 3
  • 9
  • 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. – Joseph Kern Jun 18 '09 at 17:45
  • You should rename your post .... Is there a tool to compare values in .ini files? – Joseph Kern Jun 18 '09 at 17:50
  • 1
    For OS/2: http://www.os2world.com/goran/initools.htm ;-) – splattne Jun 18 '09 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 '09 at 09:39

6 Answers6

7

Beyond Compare has a sorted INI rule you can download.

crb
  • 7,998
  • 1
  • 38
  • 53
  • 1
    Fantastic, that's exactly what I was looking for. I did briefly look at Beyond Compare before but didn't notice the sorted ini rule. In case anyone is interested, the link in your reply is for Beyond Compare 2. The "sorted ini rule" for Beyond Compare 3 is available here: http://www.scootersoftware.com/download.php?zz=kb_moreformats – ssollinger Jun 19 '09 at 13:27
  • Link from first comment not working - 404. There is another page fr BC4 only - http://www.scootersoftware.com/download.php?zz=kb_moreformatsv4 – Plamen Oct 03 '16 at 19:53
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

dummzeuch
  • 607
  • 1
  • 9
  • 20
2

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

chmeee
  • 7,370
  • 3
  • 30
  • 43
  • MY EYES! .Xdefaults! Change them! – Joseph Kern Jun 18 '09 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 '09 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 '09 at 13:23
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.

Mikeage
  • 2,741
  • 6
  • 26
  • 37
  • 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 '09 at 09:43
  • true; I'm not recommending it as an ideal, but in a pinch, it can often help – Mikeage Jun 19 '09 at 16:44
2

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

Vladimir
  • 123
  • 1
  • 1
  • 5
0

I've always liked Winmerge, very customizable.

Dave
  • 357
  • 2
  • 6
  • 18
  • 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 '09 at 09: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 '09 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 '10 at 13:30