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
mid function in for loop
Moderator: DosItHelp
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
UNTESTED:
Code: Select all
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 (
set tmp_var=%%a
echo call cv.bat !tmp_var:~0,3! !tmp_var:~3,1! !tmp_var:~4,2!>>%BFname%
)