Solved Merge .txt + deletes duplicate lines (all in batch file)

February 16, 2020 at 18:38:33
Specs: Windows 10
I'd like to make sure that when you run a file (.bat) it merges all the .txt files in the directory, and that all duplicate lines are removed.
And that at the end a pop-up appears and says how many duplicate lines have been deleted.

Thank you so much for helping me.


See More: Merge .txt + deletes duplicate lines (all in batch file)

Reply ↓  Report •

#1
February 16, 2020 at 22:23:13
✔ Best Answer
This uses vbscript:
rem BEGIN batchscript:
type *.txt | sort | deldupes.vbs > somewhere
rem END BATCH

deldupes.vbs:
'BEGIN VBSCRIPT DELDUPES
prev=""
do until wscript.stdin.atendofstream
n=wscript.stdin.readline
if n<>prev then
wscript.stdout.writeline n
prev=n
else
c=c+1
end if
loop
msgbox c
wscript.quit


Reply ↓  Report •

#2
February 17, 2020 at 15:11:07
I was hoping for a batch code, because I'd like to make it an .exe...
And I don't know how vbscript works.

I tried to put in the code:

em BEGIN batchscript:
type *.txt | sort | deldupes.vbs > somewhere
rem END BATCH
deldupes.vbs:
'BEGIN VBSCRIPT DELDUPES
prev=""
do until wscript.stdin.atendofstream
n=wscript.stdin.readline
if n<>prev then
wscript.stdout.writeline n
prev=n
else
c=c+1
end yew
loop
msgbox c
wscript.quit

In a .vbs file, but when I ran it I got an error.
Thank you very much for your help!

message edited by Tiboa123


Reply ↓  Report •
Related Solutions


Ask Question