Hi,
I'm going crazy with the special syntax of the For / F!
I have read this HOW TO: FOR /F Disabling EOF or using a quote as delim but with no result
I have a var that can contain a space and can use double quote at sorround.
Can the for /f eliminate space and double quote and leave the rest?
thanks, Einstein1969
For /F problem with double quote and space and other char...
Moderator: DosItHelp
-
- Expert
- Posts: 947
- Joined: 15 Jun 2012 13:16
- Location: Italy, Rome
Re: For /F problem with double quote and space and other cha
I'm not quite certain what you're looking for
Sounds like
but sounds also like
or like
Regards
aGerman
Sounds like
Code: Select all
set "var="Hello World""
echo %var%
set "var=%var:"=%"
echo %var%
echo %var: =%
but sounds also like
Code: Select all
set "var="Hello World""
echo %var%
for /f "delims=" %%i in ("%var%") do for /f "tokens=1,2" %%j in ("%%~i") do echo %%j&echo %%k
or like
Code: Select all
set "var="Hello World""
echo %var%
for /f tokens^=1^,2^ delims^=^"^ %%i in ("%var%") do echo %%i&echo %%j
Regards
aGerman
-
- Expert
- Posts: 947
- Joined: 15 Jun 2012 13:16
- Location: Italy, Rome
Re: For /F problem with double quote and space and other cha
aGerman wrote:I'm not quite certain what you're looking for
Sounds likeCode: Select all
set "var="Hello World""
echo %var%
set "var=%var:"=%"
echo %var%
echo %var: =%
but sounds also likeCode: Select all
set "var="Hello World""
echo %var%
for /f "delims=" %%i in ("%var%") do for /f "tokens=1,2" %%j in ("%%~i") do echo %%j&echo %%k
or likeCode: Select all
set "var="Hello World""
echo %var%
for /f tokens^=1^,2^ delims^=^"^ %%i in ("%var%") do echo %%i&echo %%j
Regards
aGerman
Thanks a lot! Work!
The third seems faster.
Einstein
Re: For /F problem with double quote and space and other cha
The third seems faster.
Maybe. But does it really matter
The question is if you're aware that all of them are working completely different?
Test again with
Code: Select all
set "var="Say "hello" to the World""
Regards
aGerman
-
- Expert
- Posts: 947
- Joined: 15 Jun 2012 13:16
- Location: Italy, Rome
Re: For /F problem with double quote and space and other cha
aGerman wrote:The third seems faster.
Maybe. But does it really matter
The question is if you're aware that all of them are working completely different?
Test again withCode: Select all
set "var="Say "hello" to the World""
Regards
aGerman
I have seen