Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
    
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: 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 9:39

6 Answers 6

up vote 6 down vote accepted

Beyond Compare has a sorted INI rule you can download.

share|improve this answer
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: scootersoftware.com/download.php?zz=kb_moreformats –  ssollinger Jun 19 '09 at 13:27

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

dzIniFileFormatter which is available from SourceForge

share|improve this answer

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

share|improve this answer
    
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
    
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

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.

share|improve this answer
    
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 9: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

I've always liked Winmerge, very customizable.

share|improve this answer
    
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 9:44
    
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

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.