I need to loop through a list of text files, and rewrite them inserting a part of their name in one of the first lines, like:
Original file name: 101f.htm
Original file content:
Line1
Line2
.
.
LineN
New file name: 101f_.htm
New file content:
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</head>
<tr>
Paciente Matricula: 101
</tr>
Line1
Line2
.
.
LineN
I achieved some result with this .bat script:
set NOME=%%~ni_.xls
set MTR=%%~ni
for /R c:\teste\teste %%i IN (*.htm) DO (
ECHO.^<head^> > %NOME%
ECHO.^<meta http-equiv^="Content-Type" content^="text/html;charset=utf-8"^> >> %NOME%
ECHO.^</head^> >> %NOME%
ECHO.^<tr^> >> %NOME%
ECHO.Paciente Matricula: %MTR% >> %NOME%
ECHO.^</tr^> >> %NOME%
ECHO. >> %NOME%
type %%~nxi >> %NOME%
PAUSE
)
It gives me all I need, except by the line:
"Paciente Matricula: 101f"
I need to remove that "f" to the line display like:
"Paciente Matricula: 101"
Thanks in advance!