Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;INI_sort.ahk by Mgis 2016-05-02
- ;very special purpose of sorting ini files, with proper regarding of sections, now also sorted
- ;param1 - ini file to sort
- #SingleInstance force
- #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
- #LTrim ; Allows continuation sections to be indented. Positional. May be turned off via #LTrim Off
- #KeyHistory 0 ; Disable keyboard and mouse event history.
- #Warn
- file=
- newfile=
- sections=
- var=
- ;SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
- CoordMode,ToolTip,Screen
- ;-----brak parametrów wyjdź
- if 0<1
- {
- MsgBox,16,Oh noes,No parameters were given!
- ExitApp
- }
- ToolTip,params received`n%1%,600,30
- ;-----czy plik istnieje
- file=%1%
- if not FileExist(file)
- {
- MsgBox,48,Yikes,File not found!
- ExitApp
- } else
- MsgBox,64,Yeah,File found!,1
- ;-----zamień na długą nazwę
- Loop %file%, 1
- file = %A_LoopFileLongPath%
- ToolTip,long path is:`n%file%,600,60,2
- ;-----ustal ścieżkę nowego bratniego pliku
- StringTrimRight,newfile,file,4
- newfile.="_new.ini"
- ;-----wczytaj listę sekcji (sortuj bo będą podane w znalezionej)
- IniRead,sections,%file%
- Sort, sections
- ;-----dla każdej z sekcji
- ;now we have them separated by linefeed, we can parse them by loop parse
- Loop,parse, sections, `n, `r
- {
- IniRead,var,%file%,%A_LoopField%
- ;-----mamy całą sekcję w var
- Sort, var
- IniWrite, %var%, %newfile%, %A_LoopField%
- ToolTip,section:`n%A_LoopField%,600,90,3
- Sleep 100
- }
- MsgBox,64,Done,Done,1
- return ;autoexec
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement