RegIniFileSort - Script for smart sorting REG and INI files

Help with writing and running scripts

RegIniFileSort - Script for smart sorting REG and INI files

Postby amr_ali » Sat Nov 10, 2012 12:35 pm

The script idea was inspired from the macros for smart sorting INI and REG files posted by mofi at the IDM user-to-user forum.


Script features

  • Smart sorting of *.reg and *.ini and similar files

    • sorting of ini section headers and registry keys
    • sorting of items of each ini section and registry key
    • special sorting of UltraEdit/UES INI file. ('Scripting' and 'Tools' sections)
    • sorting of similar files like *.prj and *.pui
  • Shuffle feature

  • Ultra-fast algorithms for sort and shuffle

Requirements

  • This script requires at least UltraEdit v13.10 or UEStudio v06.30.

  • If you plan to sort a large file with many thousands of lines, please use the script with UltraEdit v14.20.0 or UES v09.00.0 or later.

RegIniFileSort.zip
script file, version 2
(4.71 KiB) Downloaded 27 times

N.B., for users with older versions, you can use the macro posted by mofi which is compatible with all versions of UltraEdit/UEStudio.
amr_ali
Newbie
 
Posts: 3
Joined: Sat Nov 10, 2012 12:15 pm

Re: RegIniFileSort - Script for smart sorting REG and INI files

Postby Mofi » Thu Dec 06, 2012 10:17 am

Great work, very impressive.

I needed to sort today a file with registry values the first time since you published your script, used your script and compared the results with the results created by the macro. Your script worked quite well and of course was much faster than my macro.

Although the script works fine for registry files, I found 3 points for improvement:

  1. isUnicode function is needed only for UE < 16.00 and UES < 10.00 as for later versions there is an easier method to find out if the current file is a Unicode file or an ASCII/ANSI file (with the exception of rarely used ASCII Escaped Unicode files).
  2. Detection of registry files can be enhanced to support also registry files version 4 as well as registry files without a heading.
    Regedit still supports export of registry data to an ANSI file with REGEDIT4 in first line instead of a UTF-16 LE file with Windows Registry Editor Version 5.00 in first line and I use nearly always the option (file type in export dialog) to export in the older format.
    And I use my macro respectively the script mainly for files containing registry keys and values extracted from a comparison of two registry files which contains at top whether REGEDIT4 nor Windows Registry Editor Version 5.00. Those files always start directly with a registry key (sometimes after a blank line).
  3. If last line of registry file is not a blank line, a blank line could be missing after sort.
The necessary changes for point 1 and 2 were very easy to do in your script and therefore I have modified the script already. Download the attached ZIP file and compare the enhanced RegIniFileSort.js and also the slightly updated readme.txt in this ZIP file with your original version to see my changes and evaluate them.

For point 3 I give you an example and hope you can improve your script to handle this case also perfect.

There is a new ASCII file opened containing following lines with used here as placeholder for a DOS line termination.

[HKEY_CLASSES_ROOT\.txt]
@="txtfile"

[HKEY_CLASSES_ROOT\.ttf]
@="ttffile"

Sorting those 5 lines with the already enhanced RegIniFileSort.js produces:

[HKEY_CLASSES_ROOT\.ttf]
@="ttffile"
[HKEY_CLASSES_ROOT\.txt]
@="txtfile"


As you can see there is no blank line above the second registry key, but instead a blank line at bottom. A perfect result would be:

[HKEY_CLASSES_ROOT\.ttf]
@="ttffile"

[HKEY_CLASSES_ROOT\.txt]
@="txtfile"

Please note that such a file without a blank line at end is not typical. Registry files created with Regedit (version 4 and 5) end always with 2 DOS line terminators. So a really exported registry file would be

REGEDIT4

[HKEY_CLASSES_ROOT\.txt]
@="txtfile"

[HKEY_CLASSES_ROOT\.ttf]
@="ttffile"


And for such a file the result is already perfect.

If you decide to improve your script to handle this not common case for registry files with no blank line at bottom of the file also correct, please edit your first post and replace the attached ZIP file with a new one containing the script with my enhancements (if they are good in your point of view) and your improvements for this special case. I will delete the ZIP file attached to my post once your further enhanced script is available.
Attachments
RegIniFileSort_Enhanced.zip
Contains enhanced script and updated readme for evaluation.
(5.06 KiB) Downloaded 17 times
User avatar
Mofi
Grand Master
Grand Master
 
Posts: 3937
Joined: Thu Jul 29, 2004 11:00 pm
Location: Vienna

Re: RegIniFileSort - Script for smart sorting REG and INI files

Postby amr_ali » Sat Jan 12, 2013 7:27 pm

Thanks mofi for taking the time to review my script and improve it, this was very kind of you.
I was planning to refine the script with some other minor changes,
but i did not have the free time since i wrote the script :(
The changes you suggest are good and I will post an improved version this week end.
Thanks,
amr_ali
Newbie
 
Posts: 3
Joined: Sat Nov 10, 2012 12:15 pm


Return to Scripts