0

I need to implement another batch script into my batch script. I have a script that scans for strings and outputs them into a text file called "strings.txt" and I want to remove duplicate lines with another batch script. I want to implement that other batch script into mine somehow. Here is the script I need to apply.

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

I need all this to happen to my text file, but all this or a variation of this appear in my script.

Quizzed
  • 163
  • 1
  • 8
  • 1
    What does this have to do with the `DIR` command which you stated in your question. – Squashman Nov 13 '16 at 21:54
  • 1
    Possible duplicate of [Batch to remove duplicate rows from text file](http://stackoverflow.com/questions/11689689/batch-to-remove-duplicate-rows-from-text-file) – Squashman Nov 13 '16 at 21:56
  • To call another batch file from within a batch file, use `CALL`. – soja Nov 13 '16 at 22:55

1 Answers1

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

Put above in a text file and call it DeDup.vbs. To use

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

This is from Filter - 19 sub routines showing how to filter lines, sort, trim, speak, use clipboard, fetch web pages, strip tags, etc. https://onedrive.live.com/?id=root&cid=E2F0CE17A268A4FA