If you are wanting to create a script for this on a permanent basis, I don't think there is a way around doing a little bit of programming.
Something like this can be done as Sathya suggested, recording a macro, I wouldn't suggest this. Or possibly research simple batch scripting in windows (possibly a better solution). I myself think that using batch for loops with tokens is much more complicated than real programming languages.
I myself would prefer to do this in a real programming language, things like this are really easy in python, or any of the c languages.
Use StackOverflow as a resource for help if you decide to go this route.
Another suggestion I thought of is possibly using excel. I don't know what format you are forced to use, but if you can switch to a delimiter over what your format is now, you can quickly do all of this in excel. Otherwise, you have to dive into programming.