Hi scripting guru, I have a text file, look like this:
http://www.abc.com
http://www.abc.com
http://www.abc.com/123.html
http://www.def.com
http://www.xyz.com
http://www.xyz.comI would like to filter this text file using windows batch or vbs to show the unique value like this:
http://www.abc.com
http://www.abc.com/123.html
http://www.def.com
http://www.xyz.comThanks in advance !!

VBScript: With CreateObject("Scripting.FileSystemObject") Set inFile = .OpenTextFile("test.txt") Set outFile = .OpenTextFile("out.txt", 2, True) End With Set dict = CreateObject("Scripting.Dictionary") Do Until inFile.AtEndOfStream dict(Trim(inFile.ReadLine)) = True Loop For Each key In dict.Keys outFile.WriteLine key Next 'key
@echo off & setlocal EnableDelayedExpansion set row=### for /F "delims=" %%i in ('type "File.txt" ^| sort') do ( if /I not "%%i"=="!row!" (echo.%%i >> "File.new" & set row=%%i) ) ren "File.txt" "File.old" ren "File.new" "File.txt"
