Ok, atm the script I am writing a script that pulls values from several text files but can’t seem to find a good way to combine the files into a single text file.
FOR /f "tokens=%toknum% delims=:" %%G in ('"find /v /c "" "%~dp0\!systype!Win7Updates.txt""') do set maxcnt=%%G
In the text file:
KB978601,2010\MS10-019\WinSec-MS10-019-011-P57297-Windows6.1-KB978601-x86.msu,/quiet /norestart
I am trying to figure out how to create an area in a file so it will separate the stuff. I want to try and find the title, go to the title and everthing below it will be loaded.
example of what I am trying to do. (also trying to do this in CSV file) So I want the script to find the windows vista patch area and only load the ones below that area. Anyone know if that is possible?
:Windows 7 Patches
KB978601,2010\MS10-019\WinSec-MS10-019-011-P57297-Windows6.1-KB978601-x86.msu,/quiet /norestart
KB978601,2010\MS10-019\WinSec-MS10-019-011-P57297-Windows6.1-KB978601-x86.msu,/quiet /norestart
KB978601,2010\MS10-019\WinSec-MS10-019-011-P57297-Windows6.1-KB978601-x86.msu,/quiet /norestart
KB978601,2010\MS10-019\WinSec-MS10-019-011-P57297-Windows6.1-KB978601-x86.msu,/quiet /norestart
KB978601,2010\MS10-019\WinSec-MS10-019-011-P57297-Windows6.1-KB978601-x86.msu,/quiet /norestart
:Windows Vista Patches
KB978601,2010\MS10-019\WinSec-MS10-019-011-P57297-Windows6.1-KB978601-x86.msu,/quiet /norestart
KB978601,2010\MS10-019\WinSec-MS10-019-011-P57297-Windows6.1-KB978601-x86.msu,/quiet /norestart
KB978601,2010\MS10-019\WinSec-MS10-019-011-P57297-Windows6.1-KB978601-x86.msu,/quiet /norestart
KB978601,2010\MS10-019\WinSec-MS10-019-011-P57297-Windows6.1-KB978601-x86.msu,/quiet /norestart
KB978601,2010\MS10-019\WinSec-MS10-019-011-P57297-Windows6.1-KB978601-x86.msu,/quiet /norestart
Your statement “everything below it will be loaded” is not clear. I assume you mean everything below the title up until the next title. I really don’t know what you mean by “loaded” – perhaps append those lines to another file? For this solution I will simply echo the lines.
Your test case is pretty lame – the section contents are identical so it is difficult to tell if the code is working properly. Here is a more interesting test case that should be easier to interpret. I’ve added some
!characters to illustrate a problem with delayed expansion when using FOR loops.test.txt
Here is a batch script that will echo just the Vista patch section. It toggles delayed expansion on and off within the loop to protect the
!. The expansion of %%A would not work properly if delayed expansion were on.The above solution will strip any blank lines. There are tricks to preserve blank lines if needed. It will also strip any line that begins with
;because of the default FOR /F “EOL” option. Again there are tricks available to work around this if needed.