i liked your script very much that i had modified it a bit for my own usage & added a gui...
but i not too clear on why both of your scripts differ... e.g. jgpaiva's script adds a linefeed to the end of every line while TWmailrec's deletes all empty lines. is this on purpose?
in any case, here's the code & screenshot of the gui.
the modified code
; Date: Apr. 03, 2006
#Persistent
#SingleInstance force
SetBatchLines,-1
Title=Delete Duplicate Lines
GoSub, ShowMain
Return
ShowMain:
Gui, -SysMenu +MinimizeBox
Gui, Add, GroupBox, x6 y6 w360 h172, %Title%
Gui, Font, s8 CDefault, Tahoma
Gui, Add, Text, x16 y25 w180 h20, Original File:
Gui, Add, Button, x326 y45 w30 h20 gSelectFile, ...
If File =
Gui, Add, Edit, x16 y45 w300 h20 readonly vFile,
Else
GuiControl,, File, %file%
;---0---
Gui, Add, Text, x16 y80 w180 h20, Output File: ;Must not be the same...
If FileOut =
Gui, Add, Edit, x16 y100 w300 h20 readonly vFileOut,
Else
GuiControl,, FileOut, %FileOut%
Gui, Add, Button, x100 y140 w75 h25 gProcess, Process
Gui, Add, Button, x200 y140 w75 h25, Quit
Gui, Show, x270 y110 h185 w375, %Title%
Return
SelectFile:
FileSelectFile, File, 1, %A_MyDocuments%, Select text-file for processing, Text Files (*.csv; *.txt)
If File = ;user presses Cancel...
Return
GuiControl,, File, %file%
SplitPath, File,CurFile,CurFolder,CurExt,CurFileNoExt,
FileOut=%CurFolder%\%CurFileNoExt%_after.%CurExt%
GuiControl,, FileOut, %FileOut%
Return
Process:
If File =
Return
FileToRead=%File%
filetowrite=%FileOut%
;To add check-box option, to overwrite existing output file?
;IfExist,%filetowrite%
; {
; FileDelete,%filetowrite%
; }
FileRead,CompleteFile,%FileToRead%
StringSplit,index,CompleteFile,`r`n,`r`n
found=
count:=index0
count2:=count
GoSub,CreateGui2
ProgressFlag:=false
loop,%count%
{
GuiControl,2:,bar,%A_Index%
If ProgressFlag
break
position:=A_Index
Word:=index%position%
If word is space
{
FileAppend,%word%`n,%filetowrite%
continue
}
IfInString,found,%Word%
continue
count2-=1
loop, %count2%
{
position2:=position+a_index
Word2:=index%position2%
if Word=%word2%
found=%found% %Word% ,
}
Fileappend,%Word%`n,%filetowrite%
}
if found=
{
Msgbox,, %Title%, No duplicate lines were found.
GoSub, 2GuiEscape
}
else
{
StringTrimRight,found2,found,2
Msgbox,, %Title%, The following strings were repeated: %found2%
GoSub, 2GuiEscape
}
Return
CreateGui2:
Gui, 2:Add,Text,,Now checking for duplicate entries. Press esc to skip.
Gui, 2:Add, Progress,vbar w300 h20 -smooth Range0-%count%,
Gui, 2:Show, ,%Title%
Return
2GuiClose:
GoSub, ShowMain
;exitapp
2GuiEscape:
Gui, 2:destroy
ProgressFlag:=true
GoSub, ShowMain
Return
ButtonQuit:
GuiEscape:
GuiClose:
ExitApp