Help with reading file
Posted: 17 Sep 2015 09:36
I have simple text file with information like the following:
Jim:1
Tom:2
Sam:3
I have a script that will read each line a cut the string at the : storing each part in a variable with the following:
The name.txt and id.txt gets create and populated right but I can't seem to the the xname and xid to populate. Am I missing something simple?
Thanks
Jim:1
Tom:2
Sam:3
I have a script that will read each line a cut the string at the : storing each part in a variable with the following:
Code: Select all
for /f "tokens=1,2 delims=:" %%a in (sample.txt) DO (
findstr ":" sample.txt |cut -f1 -d ":" > name.txt
findstr ":" sample.txt |cut -f2 -d ":" >id.txt
set /p xname=<name.txt
set /p xid=<id.txt
echo %xname%
echo %xid%
)
The name.txt and id.txt gets create and populated right but I can't seem to the the xname and xid to populate. Am I missing something simple?
Thanks