Reputation: 39
I have a .kla file that has 2 variables (Name,ID) and I need to get their valuables and combine them to define a new name for a new file (Name_ID.kla) to be saved.
Name "Jon";
ID 1234;
I m really thankful for your help!
Upvotes: 1
Views: 79
Reputation: 1963
@echo off
set INPUT=a.txt
for /f delims^=^"^ tokens^=2 %%a in ('findstr /i "Name" "%INPUT%"') do set NAME=%%a
for /f "tokens=2 delims=; " %%b in ('findstr /i "ID" "%INPUT%"') do set ID=%%b
set FNAME=%NAME%_%ID%.kla
echo %FNAME%
a.txt contains 2 lines:
Name "Jon";
ID 1234;
output:
Jon_1234.kla
credit: rkagerer's answer in Escaping double-quote in delims
Upvotes: 1