Could you possibly create a function that returns the dynamic SQL string that you then retrieve into a text file to manipulate? I like John's view idea (we do that in a number of our scripts), but it sounds like you can't get the results of the dynamic sql to be exactly what you want. . .
What kind of cleanup is it that you need to run using your DOS script?