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