Solved Make a List from Text files without duplicate

October 28, 2011 at 12:22:46
Specs: Windows XP
I'm trying to make a list from multiple txt files, that will remove duplicates in the output.

all the txt file are in one directory and they look like this:

REM Created on 10/11/11 16:53
REM ZoneID = 1
LOI 1027 091500 0900 0030 001 001 000030 000000 00000000 000 0000vmtest1 0000
LOI 1027 091500 0900 0030 001 002 000030 000000 00000000 000 0000vmtest2 0000
LOI 1027 094500 0930 0030 001 001 000030 000000 00000000 000 0000vmtest3 0000
LOI 1027 094500 0930 0030 001 002 000030 000000 00000000 000 0000vmtest4 0000
LOI 1027 101500 1000 0030 001 001 000030 000000 00000000 000 0000vmtest1 0000
LOI 1027 101500 1000 0030 001 002 000030 000000 00000000 000 0000vmtest2 0000
LOI 1027 104500 1030 0030 001 001 000030 000000 00000000 000 0000vmtest1 0000
END

I want to be able to make a new file with just what is bold with out any duplicates.

thanks


See More: Make a List from Text files without duplicate

Report •

#1
October 28, 2011 at 17:03:05
✔ Best Answer
Please test this:

@echo off>newfile.txt
cls
setlocal 

pushd Path\to\files\                           &:: Change the path to suit your setup

for /f "tokens=*" %%1 in ('dir /b *.txt') do (
    for /f "skip=2 tokens=12" %%A in (%%1) do (
    if not defined X%%A (
       set X%%A=%%A
       echo %%A>>newfile.txt
    )
  )
)

type newfile.txt
       


Please come back & tell us if your problem is resolved.


Report •

#2
October 31, 2011 at 07:07:08
Works great!!

Thanks for your help!!


Report •
Related Solutions


Ask Question