mid function in for loop
Posted: 22 Jun 2009 07:56
Hi
I'm trying to extract characters from a string using the mid function inside a for loop. The string is from a text file. The characters I extract are used to build a command in a new batch file. I can't get the mid function to work in a for loop.
Any help???
Here's an example input file:
042N05
042O09
042O10
Here's what I want the command to look like in the new batch file:
call cv.bat 042 n 05
call cv.bat 042 o 09
call cv.bat 042 o 10
Here's the code:
set /p LFname=Enter the list file name:
set /p BFname=Enter the new batch file name:
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (%LFname%) do (
echo call cv.bat %%a:~0,3 %%a:~3,1 %%a:~4,2 >> %BFname%
)
Thanks
I'm trying to extract characters from a string using the mid function inside a for loop. The string is from a text file. The characters I extract are used to build a command in a new batch file. I can't get the mid function to work in a for loop.
Any help???
Here's an example input file:
042N05
042O09
042O10
Here's what I want the command to look like in the new batch file:
call cv.bat 042 n 05
call cv.bat 042 o 09
call cv.bat 042 o 10
Here's the code:
set /p LFname=Enter the list file name:
set /p BFname=Enter the new batch file name:
setLocal EnableDelayedExpansion
for /f "tokens=* delims= " %%a in (%LFname%) do (
echo call cv.bat %%a:~0,3 %%a:~3,1 %%a:~4,2 >> %BFname%
)
Thanks