@echo off
:: Code by oicu#lsxk.org 2007/11/29
rem chcp 437>nul
:: 看情况使用,utf-8编码的文件不能少了chcp命令,一般无需使用,
:: 但无论是否使用都不支持utf-16的文件。
:: pushd "%~dp1"
:: 如果不用pushd和popd,文件都要用绝对路径不能只用文件名。
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>1 || echo.%%j>>"%outputfile%"
)
pause
start "" notepad "%outputfile%"
:: popd
exit
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adCmdText = H0001
Set objConnection = CreateObject("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