2016-11-13 129 views
0

我需要在批处理脚本中实现另一批处理脚本。我有一个脚本可以扫描字符串并将它们输出到名为“strings.txt”的文本文件中,并且我想用另一批处理脚本删除重复的行。我想以某种方式将其他批处理脚本实现为我的。这是我需要应用的脚本。批量需要Dir命令帮助

@echo off 
setlocal disableDelayedExpansion 
set "file=%~1" 
set "line=%file%.line" 
set "deduped=%file%.deduped" 
::Define a variable containing a linefeed character 
set LF=^ 


::The 2 blank lines above are critical, do not remove 
>"%deduped%" (
    for /f usebackq^ eol^=^%LF%%LF%^ delims^= %%A in ("%file%") do (
    set "ln=%%A" 
    setlocal enableDelayedExpansion 
    >"%line%" (echo !ln:\=\\!) 
    >nul findstr /ilg:"%line%" "%deduped%" || (echo !ln!) 
    endlocal 
) 
) 
>nul move /y "%deduped%" "%~n1_deduped%~x1" 
2>nul del "%line%" 

我需要所有这些发生在我的文本文件中,但是所有这些或其变体都出现在我的脚本中。

+1

这是什么都来用你在问题中提到的“DIR”命令。 – Squashman

+1

[批处理从文本文件中删除重复行]可能的重复(http://stackoverflow.com/questions/11689689/batch-to-remove-duplicate-rows-from-text-file) – Squashman

+0

要调用另一个批处理文件在批处理文件中,使用'CALL'。 – soja

回答

1
Set Inp = WScript.Stdin 
Set Outp = Wscript.Stdout 
Set Dict = CreateObject("Scripting.Dictionary") 
Do Until Inp.AtEndOfStream 
    On Error Resume Next 
    Line=Inp.readline 
    Dict.Add Line, "" 
Loop 
For Each thing in Dict.Keys() 
    Outp.writeline thing 
Next 

把上面的文本文件放在DeDup.vbs的上面。要使用

cscript //nologo "C:\folder\dedup.vbs" < "C:\folder\inputfile.txt" > "C:\folder\outputfile.txt" 

这是过滤器 - 展示如何过滤线,排序,修剪,说话,使用剪贴板,获取网页,带标签等19个程序https://onedrive.live.com/?id=root&cid=E2F0CE17A268A4FA