I'm converting a project from delphi into c++ and there's a lot of files, I managed to get close to the script I want but still having problems, here's my current script:
Code:
set head=Classes.h
set chk="#include ""%head%"""
set out="#include <delphi/%head%>"
for %%i in (*.h) do (
call :loop_lines %%i
)
:loop_lines
set file=%1
for /f "tokens=* delims=\r\n" %%j in (%1) do (
call :chk_line "%%j"
)
rem del %1
rem rn %1.tmp %1
goto :eof
:chk_line
set line=%~1
if /i %1 == %chk% (
echo %out%
) else (
if /i "%line:~0,-1" == %chk% (
echo %out%
} else {
rem "%2"
)
)
:eof
It still outputs the occasional error of unrecognised command (project is large so I turned of echo at the line loop and turned back after), is there anyone who can fix this and explain to me what I was doing wrong? (for now leave as just echo/rem at the line part because I wanna confirm no corruption will occur before I switch to outputing to replacement files)