I'm trying to read a list of values/strings (they vary between letters and numbers) from a text file, if the value/string exist in the an output text file do nothing, else append it to the text file.
I spent over 3 days doing research and trying all sort of things and ideas. On my search I came across a post very similar (link below) to what i need to do but since i'm new to Programming and literally I have no one to ask for help, I'm hoping you guys can help me out.
Comparing Strings in Batch inside a for (if statement))
So used something very similar to the post above, but I don't know I'm just tired or I'm just blind to see where I'm doing things wrong.
@echo off
set ProjectNo=12345
set ProjectLocation=X:\Projects\123 ABC\45 WALL\G Drafting 12345\02 Models
set location=X:\Scripts
set areas=%location%\%ProjectNo%-AREAS.txt
set MAT=%location%\%ProjectNo%-MAT.txt
setlocal enableextensions enabledelayedexpansion
for /F %%a in ("%areas%") do (
set "MA=%%a"
setlocal EnableDelayedExpansion
echo(!MA!
pause
if exist "!MA!"=="!MA:%MA%=!" (
echo matched
> nul
) else (
echo nomatch
> %MAT%
)
endlocal
)
)
endlocal
pause
Content of 12345-AREAS.txt is as follow (current):
01
01
10
10
10
10
130
15
15
15
20
20
20
20
25
25
25
30
30
30
30
This list could vary from 10 - 300 values (varies a lot)
What i aim to obtain in the output file 12345-MAT.txt is single and unique value of each like so:
01
10
130
15
20
25
30