繁体   English   中英

批量使用Dir命令需要帮助

[英]Need assistance with Dir command in batch

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

@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%"

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM