| 1. |
Solve : XP pro DOS batch file editing? |
|
Answer» ghostdog74 you are a star! An observation is that although this vb script version avoids trailing spaces, my impression is that the process runs more slowly than the all batch file version.yes, that's because of the algorithm that is looping over the file. Its not efficient. Its left to you to find out why and improve on it if you are interested. Also, once you become more familiar with vbscript, you will be able to do all in one script, without going through the batch for loop...i guess that would be a bit faster...well....Hi Sidewinder, Thanks for taking another look. The problem I have now is that even with the space removed as you show below I still get an addiitional space on all the unedited lines! Quote from: Sidewinder on June 07, 2007, 04:54:09 AM Code: [Select] echo !input!>> %%x.chg In my adapted version of your original code I did remove all the spaces between input! and the > in the initial belief that this would fix it but it didn't. This bit as shown below is taken from my earlier post above: if %%i==%1 echo !input1!>> %%x.chg if not %%i==%1 ( if not "%%j"=="" echo %%i,%%j>> %%x.chg ) if not %%i==%1 ( if "%%j"=="" echo %%i>> %%x.chg ) Before I did this there were two extra spaces added to the ends of the lines when they were written out again! (The reason for the if statements is to prevent other occurrences of 60.0 in the file being changed too. I forgot to mention this in my first post)! It is a weirdy. Microsoft would probably say, "How could you possibly not want it to work this way"! Regards, Les. Les, I was able to get this to work on XP Home, but on a XP Pro rig, the batch file created the extra space. You may CALL this weirdy but Microsoft would call it a feature. I have no answer to this other than to suggest you go with the Ghostdog solution of a VBScript. In the long run VBScript is a richer language, less cryptic, more intuitive and provides more functionality for complex situations than does batch code. For more info on scripting in Windows check out the Script Center. Good luck. Sidewinder, Ghostdog, Contrex, What can I say other than thanks again for all the help and advice it is much appreciated. I can live with the time it takes the batch file/vb combination to make the CHANGES. This time last WEEK I was faced with 320 files to edit manually so the utility is a vast improvement on that situation. Sidewinder, I am perplexed that the way XP Home processes batch files is different to the way XP Pro does it. I guess we may never know why this is unless Bill Gates joins the forum! Regards, Les. |
|