I have 1 html file which contains 2 separate html file in it. I want to write a batch file that look for tag , and split original html in 2 html files.
This is what I tried
@echo off & setlocal enabledelayedexpansion
SETLOCAL DisableDelayedExpansion
set c=0
for /f "tokens=*" %%a in (split.html) do (
if "%%a" equ "</html>" (
set /a c+=1
>f!c!.html echo.
) else (
>> f!c!.html echo( %%a)
)
)
In html file, there's !
character, but in output file all of them are missing. How do keep !
in the output file?
Thanks
Update 26-07-2015 I got answer from here. Thank you all for your help. Split text file into 2 files by separator
@echo off
set /p file=FILE TO PROCESS :
del /q /f out.file*
setlocal enableDelayedExpansion
set out_file_counter=1
for /f "usebackq delims=" %%L in ("%file%") do (
set line=%%L
if "!line:~0,5!" equ "=====" (
set /a out_file_counter=out_file_counter+1
) else (
echo !line!>>out.file.!out_file_counter!
)
)
endlocal