; KillDupes - adidos - 08.15.02
; Usage: /killdupes <C:\Path\To\File.txt>
; KillDupes sorts (alphabetically) and removes duplicate lines in a text file.
; It took only 6.5s to kill 550 dupes from a 1750 line file on my computer!
; Very useful for proxy lists, names, and anything else you can think of.
; I tried to do a 650kbyte file (which has over 30,000 lines) but it took over
; 5 minutes so I ended the loop (control + break).
; I suggest you don't use this for HUGE files such as the one I tried, but it
; is great for files under 100kbytes.
alias killdupes {
; Set the amount of ticks before the loops begin!
var %kd.ticks $ticks
; Open up a window that will be sorted!
window -s @KillDupes
; Load the text file into the window!
loadbuf @KillDupes $1-
; Set the line number!
var %kd.line 1
; Loop until the last line of the window!
while (%kd.line <= $line(@KillDupes,0)) {
; Loop until the line doesn't equal the following line!
while ($line(@KillDupes,%kd.line) == $line(@KillDupes,$calc(%kd.line + 1))) {
; Delete the following line if the previous line is the same!
dline @KillDupes $calc(%kd.line + 1)
}
; Increment the line number!
inc %kd.line
}
; Save the sorted/dupe killed file to a new file!
savebuf @KillDupes $deltok($1-,-1,46) $+ .nodupes.txt
; Close the window!
window -c @KillDupes
; Echo the results to the status window!
echo -s KillDupes - Finished; Took $calc(($ticks - %kd.ticks)/1000) $+ s $+ ! Old File: $lines($1-) New File: $lines($deltok($1-,-1,46) $+ .nodupes.txt) Dupes Killed: $calc($lines($1-) - $lines($deltok($1-,-1,46) $+ .nodupes.txt))
}