If i have a variable contains names with dashes between them. I need a bat file that can split every name into a different variable depending on the dash
set variable=John-Smith-Mary-Ahmed
i want another variables with only the names
v1=John
v2=Smith
v3=Mary
v4=Ahmed
How can i do that ? thanks
@echo off
set variable=John-Smith-Mary-Ahmed
echo %variable% > c:\variable1.txtFOR /f "tokens=1-4 delims=-" %%G IN (c:\variable1.txt) DO (set v1=%%G && set v2=%%H && set v3=%%I && set v4=%%J)
ECHO %v1%
ECHO %v2%
ECHO %v3%
ECHO %v4%pause
mike
when i run the file i got
access denied
the system cannot find the file c:\vriable1.txt.
Echo is off
Echo is off
Echo is off
Echo is off
It should create the file and then access it? you could exchange the c:\ for your working directory? I guess its possible that it doesn't work in windows 7? edit: is it possible that the spelling on variable was changed accidentally? I see that it is a different spelling from the script i posted?
mike
yeah...thank you it worked when i changed the drive
