Page 1 of 1

for /f has a problem

Posted: 26 Oct 2011 15:54
by wmaddox3
i've been lurking here a couple years, great site - thanks to all...

found a problem with FOR finding a shortpath name. when any foldername has consecutive spaces... I'm just careful about my foldernames now...

for /f "delims=" %%a IN ("%filename%") DO echo %%~fsa & set filename=%%~fsa

Re: for /f has a problem

Posted: 26 Oct 2011 23:15
by abc0502
I Guess the code should be like that:

Code: Select all

FOR /F "tokens= delims=" %%a in ('find /i "X" "path\file"') do echo %%a & set p=%%a

> change the tokens and the delims according to the file
> "X" is the word in the beginning of the line and before the "delims"
> "path\file" is the path of the file
> "p" is the variable u set for the output result u find in the file
Example: find fire fox profile name, display it and set it to "p" [in windows XP]

Code: Select all

FOR /F "tokens=2 delims==" %%a in ('find /i "path=" "%appdata%\mozilla\firefox\profiles.ini"') do echo %%a & set p=%%a


i hope that help u. :)

Re: for /f has a problem

Posted: 28 Oct 2011 11:14
by aGerman
@ wmaddox3
Sorry, but I can't comprehend the problem. Of course it will fail if the file doesn't exist...

Regards
aGerman