Capturing and moving different types of text

I'm not sure I agree with your approach. Regex may work fine, but that's a pretty big Regex which will be a major hassle (at least for me) to work with. There is another feature of KM called Dictionaries which I think would work pretty effectively here. I'm not sure if you know how to use Dictionaries yet. If not, I can provide some help. I'm not an expert with them but I think I'm getting the drift of them.

Consider this approach which uses Dictionaries (it's pseudocode for the moment):

Foreach fileX in folderZ
   open FileX
   read the title
   set Dictionary1[fileX.title] to the title data
   read the number
   set Dictionary1[fileX.number] to the number data
   <<<do this for all 9 fields>>>
end loop
Delete all files in folderZ (or for safety pick a different folder!)
Foreach **number key** in Dictionary1:
       break up the Dictionary1 key into filename and field name
       append Dictionary1[filename.fieldname]'s value to Filename
    end loop
    Foreach **title key** in Dictionary1:
       break up the Dictionary1 key into filename and field name
       append Dictionary1[filename.fieldname]'s value to Filename
    end loop
    <<<Do this for all 9 fields, using the NEW ORDER in your requirement>>>
end loop

I think that's a pretty elegant solution. The first half has to read all 9 sections for each file into an appropriate dictionary. The second half has to have 8 loops which go through all the keys of a certain type and write the data for that key into a new file.

It's an interesting approach. You may not like it.

Part of the problem with any solution is that it's not clear precisely what the nature of the files could be. You gave an example, which is extremely helpful, but it's not apparent from the example what all possible variations could be. So any approach will probably require asking you for some clarifications.

I'm not entirely sure I want to write 100% of the code for you on this. If you want to try this approach, I'm very willing to assist with explaining it, but I think you should be the main coder for this, due to the fact that only you know all the variations of the text files.

I think there are completely different approaches to solving this. Perhaps we should see if other people want to suggest a different approach. I'm toying with a couple of other approaches but in the end they all have to deal with the exact same issues here.