Code: Select all
SET K0="..\GAMEPATH.TXT"
FOR /F "Tokens=*" %%V IN ('TYPE %K0%') DO (SET K1=%%V)
1
2
3
4
5
6
after AA001.bat has
1
SET K0="..\GAMEPATH.TXT"
FOR /F "Tokens=*" %%V IN ('TYPE %K0%') DO (SET K1=%%V)
2
3
4
5
6
Moderator: DosItHelp
Code: Select all
SET K0="..\GAMEPATH.TXT"
FOR /F "Tokens=*" %%V IN ('TYPE %K0%') DO (SET K1=%%V)
Code: Select all
@echo off &setlocal
set "file=AA001.bat"
setlocal EnableDelayedExpansion
<"!file!" >"!file!.~tmp" (
for /f %%i in ('type "!file!"^|find /c /v ""') do (
set "line="& set /p "line="
echo(!line!
echo SET K0="..\GAMEPATH.TXT"
echo FOR /F "Tokens=*" %%%%V IN ('TYPE %%K0%%'^) DO (SET K1=%%%%V^)
for /l %%j in (2 1 %%i) do (
set "line="& set /p "line="
echo(!line!
)
)
)
>nul move /y "!file!.~tmp" "!file!"
endlocal
Code: Select all
@echo off
setlocal EnableDelayedExpansion
for %%f in (*.bat) do (
< "%%f" (
set /P "line1="
echo(!line1!
echo SET K0="..\GAMEPATH.TXT"
echo FOR /F "Tokens=*" %%%%V IN ('TYPE %%K0%%'^) DO (SET K1=%%%%V^)
findstr "^"
) > temp.tmp
move /Y temp.tmp "%%f" > NUL
)
Code: Select all
::skip 4 lines, inject 2 lines, do the rest
::if inject more, add echo more.
::works for SKIP=0
::
::echo per 1 - no error for ABC AB!C "AB C" "AB !C" "AB&C" "AB &C" auto-quotes space &
::echo per~1 - no error for ABC AB!C AB C AB !C NO auto-quotes on space
::echo per~1 - error for AB&C AB &C
::echo "=per~1" - no error for ABC AB!C AB C AB !C NO auto-quotes on space
::echo "=per~1" - error for AB&C AB &C
::----------------------------------------------
::but inside setlocal EnableDelayedExpansion
::per 1 - no error for ABC AB!C
::per 1 - error for AB C AB !C AB&C AB &C
::per~1 - no error for ABC AB C AB!C AB !C
::per~1 - error for AB&C AB &C
::
::"=per~1" - no error for ABC AB!C AB C AB !C AB&C AB &C
:: shows error outside, no error inside
REM ****************************************************************
@echo off &setlocal
set "file=%~1"
set /A SKIP=4
setlocal EnableDelayedExpansion
<"!file!" >"!file!.~tmp" (
for /f %%i in ('type "!file!"^|find /c /v ""') do (
set "line1="& set /p "line1="
echo(!line1!
set "line2="& set /p "line2="
echo(!line2!
set "line3="& set /p "line3="
echo(!line3!
set "line4="& set /p "line4="
echo(!line4!
REM -------------------------------------------
echo SET K0="..\GAMEPATH.TXT"
echo FOR /F "Tokens=*" %%%%V IN ('TYPE %%K0%%'^) DO (SET K1=%%%%V^)
REM -------------------------------------------
for /l %%j in (1+SKIP 1 %%i) do (
set "line="& set /p "line="
echo(!line!
)
)
)
>nul move /y "!file!.~tmp" "!file!"
endlocal
Code: Select all
REM #ZTTag #ZTTemp\~ZTTag.bat -fCALL #ZTTemp\ZTW_MENU.BAT SUB %1
IF [%%1]==[SUB] GOTO SUB
CALL #ZTTemp\~ZTTag.bat
DEL #ZTTemp\~ZTTag.bat
GOTO :END
:SUB
"C:\ZTREE\BATCH2\zttag - skip insert rest 1.BAT" %%2
GOTO :END
:END