in batch text inherhalb markierungen kopieren
batchdatei die den text zwischen 2 markierungen in eine neue datei kopiert
hi, ich habe eine textdatei mit folgendem inhalt:
...text...
:markierung_1
...text...
...text...
:markierung_2
...text...
ist es in batch möglich den text zwischen den beiden markierungen in eine neue datei zu kopieren?
mfg, d4rk
...text...
:markierung_1
...text...
...text...
:markierung_2
...text...
ist es in batch möglich den text zwischen den beiden markierungen in eine neue datei zu kopieren?
mfg, d4rk
Please also mark the comments that contributed to the solution of the article
Content-Key: 112669
Url: https://administrator.de/contentid/112669
Printed on: May 4, 2024 at 14:05 o'clock
3 Comments
Latest comment
Hallo dr4rk50u1 und willkommen im Forum!
Grüße
bastla
ist es in batch möglich den text zwischen den beiden markierungen in eine neue datei zu kopieren?
Soferne keine Leerzeilen zu berücksichtigen sind, sollte das so gehen:@echo off & setlocal
set "Ein=D:\Textdatei.txt"
set "Aus=D:\Auszug.txt"
set "Von=:markierung_1"
set "Bis=:markierung_2"
set "Write="
if exist "%Aus%" del "%Aus%"
for /f "usebackq tokens=1* delims=" %%i in ("%Ein%") do call :ProcessLine "%%i"
goto :eof
:ProcessLine
echo %~1|findstr /b /c:"%Von%">nul && (set "Write=True" & goto :eof)
echo %~1|findstr /b /c:"%Bis%">nul && (set "Write=" & goto :eof)
if not defined Write goto :eof
>>"%Aus%" echo %~1
goto :eof
bastla
Hallo da draußen, ich habe ähnliches vor ... leider kopiert er mir nur eine nicht makierte zeile !? was mach ich falsch ??
@echo on & setlocal
color 3
set "Ein=Mothership-Install-Log.txt"
set "Aus=ID.txt"
set "Von=%1%"
set "Bis=%2%"
set "Write="
for /f "usebackq tokens=1* delims=" %%i in ("%Ein%") do call :ProcessLine "%%i"
goto :eof
:ProcessLine
echo %~1|findstr /b /c:"%Von%">nul && (set "Write=True" & goto :eof)
echo %~1|findstr /b /c:"%Bis%">nul && (set "Write=" & goto :eof)
>"%Aus%" echo %~1
goto :eof
@echo off
echo Operation Done...
pause
exit