VBSCRIPT Parse Large file into smaller files based on header info
Posted on 2009-04-08
I need help creating a script that will read a large file that contains multiple records (no CR/LF) and, based on a known header ("1MHG"), will create individual files. The records can be long so I'm not sure using arrays will work.
Example: the file "ALL.TXT" contains 45 records in one long string. They all start with the header info "1MHG". Knowing that, we can find the start of the next record, because it will also start with "1MHG". We do not know how the record ends. I need to be able to strip each record, from the beginning of the "1MHG" occurance to the next occurance, and write 45 files. Each file will be named sequentially (file1,txt, file2.txt, etc). I have the code that opens the file and creates the output and names them sequentially. I just cannot get the part that parses the string and strips out the records.