Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.
remove duplicate lines in txt file
Name: fcarstens Date: July 20, 2009 at 03:58:26 Pacific OS: Windows XP / Vista Subcategory: Batch
Comment:
I have a txt file called elements.txt that contains content similar to this: ---------- C:\TEMP\1000604\SAMPLEALBUM\1000604\LAST\LAST.PCK PIC_FRAME_NAME = fr_3d - beveled 01 - large landscape
---------- C:\TEMP\1000604\SAMPLEALBUM\1000604\PAGE_1\PAGE_1.PCK PIC_FRAME_NAME = fr_3d - beveled 01 - small portrait PIC_FRAME_NAME = fr_3d - beveled 01 - small portrait
I need to delete all lines starting with "-----" and all duplicate lines... so that I end up with a file looking something like this: PIC_FRAME_NAME = fr_3d - beveled 01 - large landscape PIC_FRAME_NAME = fr_3d - beveled 01 - small portrait
If I could do it in the batch file that runs all my other stuff it would be helpful. & I want to output the result to a different txt file (outfile.txt)
Name: ghostdog Date: July 20, 2009 at 04:40:15 Pacific
Reply:
vbscript
Set objFS = CreateObject("Scripting.FileSystemObject")
strFile = "c:\test\file.txt"
Set objFile = objFS.OpenTextFile(strFile)
Set d = CreateObject("Scripting.Dictionary")
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If Not InStr(strLine,"--------") >0 Then
If Not d.Exists(strLine) Then
d.Add strLine , 0
End If
End If
Loop
x=d.Items
For Each strKey In d.keys
WScript.Echo strKey
Next
Summary: I was working on a script for someone and needed a way to remove duplicate lines from a text file. I searched the forums for a solution and came across a thread where M2 mentioned his UNIQUE.COM utili...
Summary: Hello, Can anyone help with a BAT file which will open a txt file and delete the first four lines and the last five lines. The text file has a header and footer which needs to be removed: -----BEGIN...
Summary: Hy! My problem is How can get open the first line in txt file. Example: File name :"list.txt" in side file.log file2.log file3.log etc.... Im can try to open de first file (f...