Find row, manipulate, put in array and write output
Posted: 05 Aug 2010 07:56
Hello,
please help me to this problem
This is a contents of C:\file.txt
A1field1AAAfield2CCCCCCfield3
A2otherotherotherotherotherot
A3otherotherotherotherotherot
A1field1AAAfield2CCCCCCfield3
A2otherotherotherotherotherot
A3otherotherotherotherotherot
I need to take only record that begins 1,2 with A1 and take Field1,2,3
After write this records in a output file
please help me to this problem
This is a contents of C:\file.txt
A1field1AAAfield2CCCCCCfield3
A2otherotherotherotherotherot
A3otherotherotherotherotherot
A1field1AAAfield2CCCCCCfield3
A2otherotherotherotherotherot
A3otherotherotherotherotherot
I need to take only record that begins 1,2 with A1 and take Field1,2,3
After write this records in a output file
Code: Select all
@Echo OFF
call :find_records C:\file.txt
write array linefound.%count% to newfile.txt
:find_records
SET /A count=0
FOR /F %%j IN ('FINDSTR "A1" %1') DO (
SET /A count=count+1
SET line2=%%j
CALL SET field1=%%line2:~3,6%%%
CALL SET fieldFIX=PIPPO
CALL SET field2=%%line2:~12,6%%%
CALL SET field3=%%line2:~24,6%%%
CALL SET linefound.%count% = %field1% fieldFIX %field2% %field3%
)
GOTO:EOF