For /f skip not working

May 4, 2012 at 09:25:09
Specs: Windows XP
Have a business site that was using a POS that apparently broke and started writing invoice files to local text on each POS station.

Sample of Text File here:


The information in this file was NOT posted to your POS data files.
Print and keep for your records.
>> A NETWORK ERROR OR DATA FILE LOCKING ERROR HAS OCCURRED <<
Erase folder called C:\_POSDATA to deactivate the Pink Box.

- - > > > INVOICE < < < - -

Store name here
123 Any St
Anytown, USA, 45745

Phone: 123-456-7890

Date: 04/09/2012 INVOICE782402
Time: 11:45:21 Clerk: Jim

Account: CASH
Customer: CASH CUSTOMER

SKU Qty Description Extended
=====================================================================
4842384 1.00 DUVALIN AVELLANA/VANILLA 1.99
==============
Total: 1.99
Tax: 0.00
Grand Total: 1.99

Tender: 2.00
Change: 0.01

Cash: 2.00

> > Error Posting This Information < <

End of sample file

So they have hundreds of these. They needed to know the sub-total and tax amount.

I had started to write a batch file that would pull those numbers out of each batch file, but haven't gotten that far with it and I'm already stumped.

@echo off
for /f "skip=8 tokens=3" %%a in (testfile.txt) do set
var=%%a
echo "%var%"

Trying that just to see if I'm grabbing the right number, but the skip part doesn't seem to be working. It's always pulling from the last line.

> > Error Posting This Information < <

What am i doing wrong there?

Also, since there are hundreds of these and the filenames all start with INVC-xxxxxx (x's are invoice numbers) that I could include in the batch file to go through all those files and output those two numbers to another text file.

Or, still run through all the files, grabbing those numbers (tax & subtotal) and writing a file that will add the tax lines together as it goes through each file.

Sorry for so many questions, and I appreciate the help.

Noticed after posting, that the sample text file is showing here as left aligned. It's center aligned in the text file. Thanks


See More: For /f skip not working

Report •


#1
May 4, 2012 at 19:34:17
Examine the input file using a hex editor to ensure that the expected lines exist.

Report •
Related Solutions


Ask Question