Input variables from file

January 30, 2010 at 01:06:18
Specs: Windows XP, 2GB

I have gone through this forum and I have not been able to find exactly what I am looking for.

I want to create a batch script (XP) to basically

1. Read values from a text file (text.txt)

The text file would be in such a format:


2. I already have the script in place for user input. The user input would be 1A, 1B or 1C. This would then match and pickup the three values proceeding and store it to three separate variables. Is this possible?

Many thanks in advance.

See More: Input variables from file

Report •

January 30, 2010 at 03:44:22
@echo off
set /P in=Enter value^>
for /F "tokens=1-4 delims=," %%A in ('type text.txt ^| find "%in%"') do (
  set var1=%%B
  zst var2=%%C
  set var3=%%D
echo %var1% - %var2% - %var3%

Report •
Related Solutions

Ask Question