SetBatchLines -1 ; The below section is for testing. A compiled version should work with arguments 1 = MyScript.ahk ; Inputfile 2 = MyScriptWithLineNumbers.txt ; Outputfile (copy of Inputfile with line numbers) 3 = IOCF ; Save result within Inputfile/Outputfile/Clipboard/FileName 0 = 3 Loop, Read, %1% ; Get total (number of lines) { LC = %A_Index% } StringLen, LH, LC ; Get length of total, to set the line number format Loop, Read, %1%, %2% { If A_LoopReadLine = ; If line is "empty" ... { LC -= 1 ; reduce total EL += 1 ; count the empty line } LN = %A_Index% SetFormat, float, 0%LH%.0 ; Set prefix based on length of total LN += 0.0 Status = |Total:%LN%|Empty:%EL%|Written:%LC%| ; Create result If 0 >= 2 ; Create Outputfile (copy of Inputfile with line numbers) FileAppend, %LN% %A_LoopReadLine%`n } IfInString, 3, I ; Append result to the Inputfile FileAppend, `; %Status%, %1% IfInString, 3, O FileAppend, `; %Status%, %2% ; Append result to the Outputfile IfInString, 3, C ClipBoard = %Status% ; Copy result to the ClipBoard IfInString, 3, F FileCopy, %1%, %LN%.%EL%.%LC%_%1% ; Create a copy of InputFile with the result as part of its filename
Tweaking would be very much appreciated. Have Phun. Thx.
8)