Computer Hope

Microsoft => Microsoft DOS => Topic started by: ram on April 24, 2017, 08:48:20 PM

Title: Unable to copy files containing html tags after adding text inside it.
Post by: ram on April 24, 2017, 08:48:20 PM
Hi everyone,
Thanks for this siteit helped me a lot in doing my project but i am facing some issue,hope you can suggest me how to get out of this...

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.

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"
)


 **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 output eml:**
   Date Mon,20 mar 2017
   From:[email protected]
   To:[email protected]
   Message-ID:<10091223>
    Subject:Symphony
   echo X-SUBTYPE=RETURES
   x-globalrelay-MsgType: XXXX
   x-StreamType:xxxx
   x-contentstartdate:XXX
    < Yay1R0QgoH.............. </html>
 
as shown above after executing the script the html tags at the begining are missing i am not able to find out why....can any one help me with this
Title: Re: Unable to copy files containing html tags after adding text inside it.
Post by: Hackoo on April 25, 2017, 02:07:38 AM
Hi  ;)
You got an answer here, so check it (http://stackoverflow.com/questions/43595909/windows-batch-scripting-unable-to-copy-files-containing-html-tags-to-another-fi) !