Solved for command tokens not working

December 24, 2012 at 09:57:32
Specs: Windows 7
This is driving me mad. Simple crap yet fails.
@echo off & setlocal enabledelayedexpansion
set x=?
set /P x=Enter details of new xxx in format [blahblah1,blahblah2]
for /f "tokens=1,2 delims=," %%a in ('echo.%x%') do (
set first=%%a
set second=%%b
)
echo.%first%
echo.%two%
pause > nul
Now when i run this, the WHOLE string is parsed into %first% what can possibly be going wrong? I want the first part blahblah1 to be set into the first variable and the blahblah2 to be set to the second variable. How can this be done?

See More: for command tokens not working

Report •


#1
December 24, 2012 at 10:18:09
//edit
The comma isn't supported unless you use nbrane's solution, so what i did to fix it was replace the comma with - and it worked. The variables are screwed up since i was clearly screwed up that day.

Report •

#2
December 24, 2012 at 13:21:02
✔ Best Answer
Actually, i don't think the dot had anything to do with it. You must have fixed something else, but if it's working....
for /f "tokens=1,2 delims=," %%a in ("%x%") do
fixed it on my end, but i don't know why. The comma in "delims" gets replaced with a space when 'echo %x%' is used, but not this other way.

Report •

#3
December 25, 2012 at 02:56:02
Have you tried using the same variable for the echo. Looks like you use both second and two?

:: mike


Report •

Related Solutions


Ask Question