Posted by Valerie on October 01, 2011 at 20:37:20:
In Reply to: dos posted by roggerpt on September 30, 2011 at 11:58:55:
Your script demonstrates lack of understanding of batch scripting. Neither Tokens nor Delims are specified so the default Delim of space is used and extracts only the first word from the lines in Makfi.txt. ex3 and ex5 are not defined in the script, the If command line will never return True if you compare Foo and ex3 unless ex3 is the first word of a line in Makfi.txt
Please test the following script:
@echo off>text.file
SETLOCAL ENABLEDELAYEDEXPANSION
cls
set ex3=the current user logged
set ex5=there is no current user logged
for /f "tokens=*" %%a in (makfi.txt) do (
set foo=%%a
if /i "!foo:~0,23!" equ "!ex3!" (set foo=!ex5!)
echo !foo! >> text.file
)