Recently need to remove the duplicate content, so I thought of using bat or VBS implementation, did not expect to have been written on the internet, testing is just learning
How to: Drag the text onto the batch process ...
@echo
off:: Code by oicu#lsxk.org 2007/11/29
rem chcp 437>nul
:: See Use, UTF-8 encoded files can not be less chcp command, generally no use, :
: But utf-16 files are not supported regardless of whether they are in use or not. ::
pushd "%~dp1"
:: If you do not use pushd and popd, the file must use absolute path not only file names.
if "%~1" = "" goto:eof
set outputfile=%~dpn1_output%~x1
type nul> "%outputfile%"
echo waiting ...
for/f "tokens=1* delims=:"%%i in (' findstr/n. * "%~1"] Do (
findstr/b/e/c: "%%j" "%outputfile%" >nul 2& gt;&1 | | Echo.%%j>> "%outputfile%"
)
pause
Start "" Notepad "%outputfile%":
: popd
exit
"In Oicu (oh! I-you!) The masterpiece said: "
: It's OK to repeat. The disadvantage is to slow and keep the original blank line.
The following is the code for the VBS implementation
The following is the source code for this script, copied after the file saved as a VBS suffix, double-click to run. Files to be placed in the C-packing Text.TXT, please pay special attention to: a line of text in a record, do not have blank lines.
Const ADOPENSTATIC = 3
Const ADLOCKOPTIMISTIC = 3
Const adCmdText = &h0001
Set objconnection = Createobjec T ("ADODB.") Connection ")
Set objRecordSet = CreateObject (" ADODB. Recordset ")
strpathtotextfile =" C:\ "
strfile =" Test.txt "
objconnection.open" provider= " Microsoft.Jet.OLEDB.4.0 "& _
" Data source= "& strPathToTextFile &"; "& _
" Extended properties= "" Text; Hdr=no; Fmt=delimited "" "
objrecordset.open" select DISTINCT * from "& strfile, _
objconnection, adOpenStatic, adLockOptimistic, adCmdText do
Until objrecordset.eof
Set objFSO = CreateObject (" Scripting.FileSystemObject ")
set Fp=objfso.opentextfile (" C:\test1.txt ", 8,true,0)
Fp. WriteLine objRecordSet.Fields.Item (0). Value
fp.close
Set objFSO = Nothing
objrecordset.movenext
Loop