簡體   English   中英

批處理文件,用於從另一個文本文件中刪除一行

[英]batch file to delete lines of one text file from another

我有兩個文本文件-blacklist.txt和complete.txt。 我想要一個批處理文件而不是bash文件代碼。 我想刪除兩個文件之間的共同點。 黑名單文件中的名稱應該從complete.txt文件中刪除嗎?

findstr /v /x /g:blacklist.txt complete.txt >outfile.txt

應該刪除所有條目blacklist ,從complete生產outfile

這將執行Unicode輸入和輸出。 命名為something.vbs。

Set Arg = WScript.Arguments
set WshShell = createObject("Wscript.Shell")
Set Fso = CreateObject("Scripting.FileSystemObject")
Set BlackFile = Fso.OpenTextFile(Arg(0), 1, False, -1)
Set CompleteFile = Fso.OpenTextFile(Arg(1), 1, False, -1)
Set OutputFile = Fso.CreateTextFile(Arg(2), True, True)
Set Dict = CreateObject("Scripting.Dictionary")
On Error Resume Next
Do Until BlackFile.AtEndOfStream
    Line=BlackFile.readline
    Dict.Add Line, ""
Loop
Do Until CompleteFile.AtEndOfStream
    Line=CompleteFile.readline
    If Dict.Exists(Line)
        OutputFile.Writeline Line
    End If
Loop

在命令提示符下使用。

C:\folder\something.vbs black.txt complete.txt newfile.txt

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM