Here is a script I wrote that will remove duplicate lines and blank lines from INI INF TXT file types. You can use this script 2 ways
1:\ Drag and Drop the file onto the script
2:\ Cmd Line
Quote
cscript %UserProfile%\Desktop\RemoveLines.vbs D:\MyTemp\Test1.Txt
This will then produce a file called New_FileName.Extension
Test File Contents
Quote
[Section 01 Test]
Line 01 Test
LINE 01 TEST
LINE 01 Test
Line 01 TEST
line 01 test
lINE 01 tEST
Line 01 Test
LINE 01 TEST
LINE 01 Test
Line 01 TEST
line 01 test
lINE 01 tEST
[Section 02 Test]
Line 02 Test
Line 02 Test
[Section 03 Test]
Line 03 Test
Line 02 Test
[Section 04 Test]
Line 04 Test
Line 03 Test
[Section 05 Test]
Line 05 Test 1
Line 05 Test 2
[Section 06 Test]
Line 06 Test
Line 03 Test
Results Of Script
Quote
[Section 01 Test]
Line 01 Test
[Section 02 Test]
Line 02 Test
[Section 03 Test]
Line 03 Test
[Section 04 Test]
Line 04 Test
[Section 05 Test]
Line 05 Test 1
Line 05 Test 2
[Section 06 Test]
Line 06 Test
Save As RemoveLines.vbs
Dim Dic :Set Dic = CreateObject("Scripting.Dictionary")
Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")
'-> Drag One File
If WScript.Arguments.Count = 1 Then
'-> Process INF, INI,TXT
Select Case LCase(Right(WScript.Arguments.Item(0),3))
Case "inf","ini","txt"
TextChange(WScript.Arguments.Item(0))
Case Else
'-> Not Correct File Type
MsgBox "This file is not a valid file type : " & _
Right(WScript.Arguments.Item(0),3) & vbCrLf & _
"Drag And Drop These Types INF INI TXT",4128,_
"Error Wrong File Type"
WScript.Quit
End Select
'-> No File Drag
ElseIf WScript.Arguments.Count = 0 Then
ErrorMsg("Error File Total : " & WScript.Arguments.Count)
'-> To Many Files Drag
ElseIf WScript.Arguments.Count >= 2 Then
ErrorMsg("Error File Total : " & WScript.Arguments.Count)
End If
'-> Function To Handle To Many Or Zero Files
Function ErrorMsg(N)
MsgBox _
"There must be only 1 Text File Type Drag And Drop" & vbCrLf & _
"onto this script. " & N,4128, N
WScript.Quit
End Function
'-> Remove Duplicate Lines
Function TextChange(File)
Dim Ts, Tx
Set File = Fso.GetFile(File)
Set Ts = Fso.OpenTextFile(File.Path)
'-> 1 = Case Insensitive , 0 = Case Sensitive
Dic.CompareMode = 1
Do Until Ts.AtEndOfStream
Tx = Ts.ReadLine
If Not Dic.Exists(Tx) Then Dic.Add Tx, Tx
Loop
Ts.Close
Set Ts = Fso.CreateTextFile( _
Replace(File.Path,File.Name, "New_" & File.Name))
For Each Tx In Dic.Keys
If Not Tx = "" Then Ts.WriteLine Tx
Next
Ts.Close
End Function
Sorry for the double attach file I am on Windows 8 and I can not remove one from the post,
the site not quite right on Win 8