Hey,
I've been using a command in a batch file to find the records count in a large BARDATA file. What I have is working but I believe it's just been by dumb luck to this point.
The nutshell; BARDATA uploaded through serial port using putty as a data logger. This is barcode data from stores and warehouses. It gets put on a Unix server running an oracle database where a program absorbs that data and places it into the proper tables. This file cannot be touched, or it will break the oracle sql process.
I have to search this large file with extremely long lines of wrapping data for the records count and end character.
Records count string )****** The 6 characters following the open bracket are the total records and could be anything between )000001 - )999999
with the end Character of W)=Warehouse R)=Receiving S)=showroom M)=movement
because I don't know what the data will be or how many records there are and in effort to keep from having to search this file several times for each ending character as this file at any given moment can be 750 bytes or up to 8 megabytes and the ending ) bracket doesn't seem to be displayed, I did this in my batch,
command:
FOR /F "tokens=*" %%g IN ('type BARDATA ^|findstr ")"') do (SET RECORDS=%%g)
CLS
SET _result=%RECORDS:~-1%
SET log_result=%RECORDS:~-20%
echo Record count: %log_result% >c:\DC\Program\logs\RECORDS.txt
if "%_result%" == "R" GOTO :NAMEDATA
if "%_result%" == "W" GOTO :NAMEDATA
if "%_result%" == "S" GOTO :NAMEDATA
if "%_result%" == "M" GOTO :NAMEDATA
While this does work I get this error from FINDSTR and its just a matter of time before this record count string ends up at the end of a line to long and it partly wraps onto the next line.
FINDSTR: Line 1 is too long.
FINDSTR: Line 1 is too long.
FINDSTR: Line 1 is too long.
FINDSTR: Line 1 is too long.
FINDSTR: Line 1 is too long.
FINDSTR: Line 1 is too long.
FINDSTR: Line 1 is too long.
FINDSTR: Line 1 is too long.
FINDSTR: Line 1 is too long.
(SET RECORDS=U064144102365 U738749002220 U064144102365 U738749002220 U738749002220 U064144102365 U064144102365 U064144102365 U738749002220 U738749002220 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 Q00500 )003563 W )
Might anyone have a better way of doing this. But it must be in BATCH.
Note the raw data is continues and what you see above is only how it paste into this editor. The pattern is really a stairstep fasion from start to end.
Like:
U064144102365 U738749002220 U064144102365 U738749002220 U064144102365 U738749002
64144102365 U064144102365 U064144102365 U064144102365 U064144102365 U064144102365
365 U064144102365 U064144102365 U064144102365 U064144102365 U064144102365 U0641
U738749002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365
49002220 U064144102365 U738749002220 U064144102365 U738749002220 U064144102365