Page 1 of 1

wincmd.ini: Sort a list of settings in alphabetical order

Posted: 2017-11-18, 19:44 UTC
by misvin
Hi,
Sometimes a user needs to edit manually the wincmd.ini file.
wincmd.ini includes dozens of sections with hundreds of lines (settings).
When Total Commander saves the changes made to the file wincmd.ini, it also changes the position of some sections and/or settings in wincmd.ini.

I suggest always to save all sections (with their relevant settings) in the alphabetical order (A-Z).

Example:

[1600x900 (8x16)]
CompareDivider=500
CompareDX=120
..............
FontName=Microsoft Sans Serif
FontNameDialog=Microsoft Sans Serif
.............
x=288
y=19

[Associations]
.....
[Colors]
ActiveTitle=8388608
ActiveTitleText=16777215
BackColor=-1
............

Posted: 2017-11-18, 20:07 UTC
by Dalai
It would be nice, but I doubt it's possible. AFAIK TC just calls WritePrivateProfileString API function which does all the writing to the file; it's probably also responsible for moving whole sections within the file (not sure about that, but it's an educated guess).

Regards
Dalai

Posted: 2017-11-19, 15:08 UTC
by Hacker
misvin,
Here is a short AHK script that sorts the .ini file. Test on a backup first.

Code: Select all

#NoEnv

IniFileName = C:\Program Files\Totalcmd\wincmd.ini

IniRead, SectionNames, %IniFileName%
Sort, SectionNames, CL
Loop, Parse, SectionNames, `n
{
	IniRead, Section, %IniFileName%, %A_LoopField%
	Sort, Section, CL
	NewIni = %NewIni%[%A_LoopField%]`n%Section%`n`n
}
StringTrimRight, NewIni, NewIni, 1
FileDelete, %IniFileName%
FileAppend, %NewIni%, %IniFileName%
HTH
Roman

Posted: 2017-11-19, 15:39 UTC
by misvin
Hacker wrote:misvin,
Here is a short AHK script that sorts the .ini file. Test on a backup first.
I have sorted manually all settings (thanks to Excel :-)) and saved the wincmd.ini file.
But next time when I run TC, the alphabetical order (A-Z) is corrupted because of [lefttabs] and [righttabs] sections, and because of other settings.

Please note that TC should be closed before I edit wincmd.ini.

Posted: 2017-11-19, 16:38 UTC
by Hacker
misvin,
I have sorted manually all settings (thanks to Excel :-)) and saved the wincmd.ini file.
But next time when I run TC, the alphabetical order (A-Z) is corrupted because of [lefttabs] and [righttabs] sections, and because of other settings.
Yes, that's why the script can come in handy.

Roman

Posted: 2017-11-24, 22:20 UTC
by misvin
Hacker wrote:Yes, that's why the script can come in handy.
Can this script (or similar code) be implemented in TC official release?

Posted: 2017-11-27, 07:52 UTC
by MVV
misvin,
I don't think that such thing will be ever integrated into official TC release because it is not required for normal TC work, order of INI entries have no impact on TC work. I can only suggest to have such script somewhere and run it when you need to edit wincmd.ini if you really want to see entries sorted alphabetically (I prefer to see more important sections first, e.g. [Configuration]).