Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <pre><code> @echo off ::get the line before desired tag for /f "tokens=1 delims=:" %%L in ('findstr /n "&lt;conf-front&gt;" some.xml') do set /a line=%%L-1 ::create empty file break&gt;"%temp%\empty" ::get first &lt;%line%&gt; lines of the file fc "%temp%\empty" "some.xml" /lb %line% /t |more +4 | findstr /B /E /V "*****" &gt;temp.xml :: add additional content echo ^&lt;!--Delivery Date: 07/23/2013--^&gt; &gt;&gt; temp.xml echo ^&lt;!--XML Script: sdfasdfdfs--^&gt; &gt;&gt; temp.xml echo ^&lt;!--Batch: sdfsdfdssfs--^&gt; &gt;&gt; temp.xml ::get last &lt;%line%&gt; lines of the file type "some.xml" | more +%line% &gt;&gt; temp.xml ::delete temp empty file del /Q /F "%temp%\empty" </code></pre> <p>This will create temp.xml file and you can check if it fits on your needs and then copy it over your old file.Will set this before <strong>last</strong> <code>&lt;conf-front&gt;</code> tag so I hope there's only one of this kind.And change <code>some.xml</code> with the name of your xml everywhere in the code.</p> <p><strong>EDIT</strong> ~ do this with all .xml in a folder (will not affect subfolders)</p> <pre><code> @echo off rem cd /d "c:\some_dir" ::create empty file break&gt;"%temp%\empty" :: iterate trough the xml files setlocal enableDelayedExpansion for %%X in (*.xml) do ( set "line=" ::get the line before desired tag for /f "tokens=1 delims=:" %%L in ('findstr /n "&lt;conf-front&gt;" %%~dpsnxX') do set /a line=%%L-1 ::only in case the tag is presented if defined line ( ::get first &lt;%line%&gt; lines of the file fc "%temp%\empty" "%%~dpsnxX" /lb !line! /t |more +4 | findstr /B /E /V "*****" &gt;%temp%\temp.%%~nX.xml :: add additional content echo ^&lt;^^!--Delivery Date: 07/23/2013--^&gt; &gt;&gt;"%temp%\temp.%%~nX.xml" echo ^&lt;^^!--XML Script: sdfasdfdfs--^&gt; &gt;&gt;"%temp%\temp.%%~nX.xml" echo ^&lt;^^!--Batch: sdfsdfdssfs--^&gt; &gt;&gt;"%temp%\temp.%%~nX.xml" ::get last &lt;%line%&gt; lines of the file type "%%~dpsnxX" | more +!line! &gt;&gt;"%temp%\temp.%%~nX.xml" ) ) endlocal :: replace the file with these in temp folder with new content for %%X in (*.xml) do ( move /Y "%temp%\temp.%%~nX.xml" "%%~dpnxX" 2&gt;nul ) ::delete temp empty file del /Q /F "%temp%\empty" </code></pre> <p>Just change <code>c:\some_dir</code> with your own path.And back-up your dir..</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload