I currently have a batch file that is going through a text file and assigning each line into an array. I want to iterate through the loop and remove a certain number of characters from every value in the array. Is this possible to do?
@ECHO off
findstr /C:"number" /C:"type" testFile.txt > oneresult.txt
set "file=oneresult.txt"
set /A i=0
timeout /t 1
echo ---------------Results--------------- > results.txt
for /f "tokens=*" %%x in (oneresult.txt) do (
call echo %%x >> results.txt
call set array[%i%]=%%x
set /A i+=1
)
call echo %i% files received >> results.txt
del "oneresult.txt"
So right now it just prints the retrieved strings from testFile.txt and then they are eventually placed into result.txt. I would like all the strings that come from the testFile.txt to have the first 10 characters removed. If there is an easier way please let me know. So far this is what I have found but I am also a bit of a batch noob.
Just figured it out without the array and posting the answer for anyone else that may be searching in the future:
@ECHO off
findstr /C:"number" /C:"type" testFile.txt > oneresult.txt
set /A i=0
timeout /t 1
echo ---------------Results--------------- > results.txt
for /f "tokens=*" %%x in (oneresult.txt) do (
setlocal enabledelayedexpansion
call set print=%%x
call set newprint=!print:~32!
call echo !newprint! >>results.txt
endlocal
set /A i+=1
)
call echo %i% files received >> results.txt
del "oneresult.txt"