ChrisHallJJ
Programmer
I want to write a batch file to read a file and substring a portion of the data to write to another file. The file looks like this 000004045
000005025
I can assign a value to a variable and substring it:
SET _string=1234567890
SET _substring=%_string:~5,3%
echo %_substring%
Result is: 678
I can read from a file:
FOR /F %%i IN (c:\a\test.txt) DO @echo %%i
Result is: 000004045
000005025
I can not read from a file and subtring the line:
FOR /F %%i IN (c:\a\test.txt) DO (SET _substring=%%i:~5,4%,@echo %_substring%)
Result is: (SET _substring=000004045:~5,4_substring )
(SET _substring=000005025:~5,4_substring )
How would I do this? Thanks so much, Chris
000005025
I can assign a value to a variable and substring it:
SET _string=1234567890
SET _substring=%_string:~5,3%
echo %_substring%
Result is: 678
I can read from a file:
FOR /F %%i IN (c:\a\test.txt) DO @echo %%i
Result is: 000004045
000005025
I can not read from a file and subtring the line:
FOR /F %%i IN (c:\a\test.txt) DO (SET _substring=%%i:~5,4%,@echo %_substring%)
Result is: (SET _substring=000004045:~5,4_substring )
(SET _substring=000005025:~5,4_substring )
How would I do this? Thanks so much, Chris