Recursive Batch File

Posted by MCZ on Super User See other posts from Super User or by MCZ
Published on 2012-10-24T09:08:21Z Indexed on 2012/10/24 11:04 UTC
Read the original article Hit count: 282

Filed under:
|
|

I have a file that looks this:

head1,head2,head3,head4,head5,head6
a11,a12,keyA,a14,a15,a16
a21,a22,keyB,a24,a25
a31,a32,keyC,a34
a41,a42,keyB,a44,a44
a51,a52,keyA,a54,a55,a56
a61,a62,keyA,a64,a65,a66
a71,a72,keyC,a74
some message

Objective: Write list of unique keys to a text file. For example, the result for the file described above should be:

keyA, keyB, keyC

Here's the pseudocode I would like to implement in batch file recur.bat

  1. Read second line of inputfile
  2. If no key exist on second line, return else continue
  3. Append keyX to list
  4. FINDSTR /v keyX inputfile
  5. Pipe results to recur.bat

I don't know if this is the most efficient way to do this without using actual programming language.

Any suggestions for actual batch file code?

© Super User or respective owner

Related posts about batch

Related posts about recursion