I have never done any batch scripting before and so I need help in building one of them.
We have a file say “GetHistory.bat” and it accepts a parameter ID. The output of the script is as shown below:
Activity Name Status Date
----------------------------------------
Act1 Created 1-Jan-2013
Act2 Submitted 2-Jan-2013
Act3 Approved 2-Jan-2013
Now the problem is I need to export the output in txt as CSV without the header and parameter ID added to each line as below:
1001,Act1,Created,1-Jan-2013
1001,Act2,Submitted,2-Jan-2013
1001,Act3,Approved,2-Jan-2013
Any help to begin the script would be highly appreciated.
Thanks…!
With the assumption that the output of
GetHistory.bathas been redirected into a file calledhistory.txt, we could feed that into our new batch file,ParamCSV.bat, like so, with this result:To put together a quick script for this, I’ve referenced info from:
I came up with this batch script,
ParamCSV.bat:There are a number of assumptions that are made here, and if any of them change or are invalid, the script will break:
GetHistory.bathas fixed-width columns, of width 17,11, and 11. You didn’t provide an example of a two-digit day, so I’ve assumed the dates are right-aligned.forstatement.