As part of a project I need to add text to the middle of many files using batch scripting. I am able to add the text successfully, but after copying the files to a new location I noticed that the HTML tags are missing. I only have this problem in Windows Server 2012/2008; in Windows 7 the HTML tags remain intaact.
My Code snippet:
@echo off
set SrcFolder=C:\Users\emlfilessample
set DstFolder=C:\Users\output
FOR %%f in (%SrcFolder%*.eml) do (
(FOR /F "usebackq delims=" %%a in (`"findstr /n ^^ %%f"`) do (
SETLOCAL EnabledDelayedExpansion
set "var=%%a"
set "var=!var:*:=!"
if "!var:~0,10" == "x-globalre" (
echo X-SUBTYPE=RETURES
)
echo(!var!
ENDLOCAL
)) >> "%DstFolder%\%%~nxf"
)
Below is my sample input file...
**Sample input eml:**
Date Mon,20 mar 2017
From:[email protected]
To:[email protected]
Message-ID:<10091223>
Subject:Symphony
x-globalrelay-MsgType: XXXX
x-StreamType:xxxx
x-contentstartdate:XXX
<html><body> Message ID:sm9atRNTnMA=Yay1R0QgoH.............. </html>
After executing my script in Server 2012 I am able to successfully inject the required text in the middle, but as I said the HTML tags are missing:
**Sample input eml:**
Date Mon,20 mar 2017
From:[email protected]
To:[email protected]
Message-ID:<10091223>
Subject:Symphony
X-SUBTYPE=RETURES
x-globalrelay-MsgType: XXXX
x-StreamType:xxxx
x-contentstartdate:XXX
<Yay1R0QgoH.............. </html>
As said I am able to generate the desired output by adding the text in the middle in Windows 8 with the same script. I am not able to identify why it is giving different output(html tags are missing)in Windows Server 2012.