Hi guys i need little help with batch script…
from file something.txt which contain
data
data
LastLogedUser=John.Doe
data
data
i want to find the string LastLogedUser= and append the text after that (in this case "John.Doe" like a variable in copy of other file…
Like this but something is wrong in my code:
for /F "delims=" %%a in ('findstr /I "LastLogedUser=" something.txt') do set "uniuser=%%a"
echo User is: %uniuser%
copy fpr_log.txt c:\fpr_log%uniuser%.txt
Best Answer
Something is wrong in my code
findstr /I "LastLogedUser=" something.txt
is returning the whole line from the file:So your
for
loop needs to use=
as a delimiter and get the second token in order to extractJohn.Doe
.I've also added some
"
s in case there are spaces in the user name ...Corrected batch file:
Further Reading