here what i have...
Code: Select all
@echo off
type "C:\Temp\HSTY.txt" | findstr /r /v /c:"^End of Transfer" >> "C:\Temp\Temp.log"
Moderator: DosItHelp
Code: Select all
@echo off
type "C:\Temp\HSTY.txt" | findstr /r /v /c:"^End of Transfer" >> "C:\Temp\Temp.log"
Code: Select all
@echo off &setlocal
set "infile=C:\Temp\HSTY.txt"
set "outfile=C:\Temp\Temp.log"
set "search=End of Transfer"
set "found="
del "%outfile%" >nul 2>&1
for /f "tokens=1*delims=:" %%i in ('type "%infile%" ^| findstr /n "^"') do (
if not defined found echo(%%j>>%outfile%
if /i "%%j"=="%search%" set "found=TRUE"
)
endlocal
Code: Select all
@echo off &setlocal
set "infile=C:\Temp\HSTY.txt"
set "outfile=C:\Temp\Temp.log"
set "search=End of Transfer"
set "found="
del "%outfile%" 2>nul
for /f "delims=:" %%i in ('type "%infile%" ^|findstr /inc:"%search%"') do if not defined found set /a found=%%i
if not defined found echo(%search% not found in %infile% &goto:eof
for /f "tokens=1*delims=:" %%i in ('type "%infile%" ^|findstr /n "^"') do if %%i leq %found% echo(%%j>>"%outfile%"
endlocal
daillest319 wrote:I need to delete everything after the word "END OF TRANSFER"
Code: Select all
@echo off &setlocal
set "infile=C:\Temp\HSTY.txt"
set "outfile=C:\Temp\Temp.log"
set "search=End of Transfer"
set "found="
del "%outfile%" 2>nul
for /f "delims=:" %%i in ('type "%infile%" ^|findstr /inc:"%search%"') do if not defined found set /a found=%%i
if not defined found echo(%search% not found in %infile% &goto:eof
for /f "tokens=1*delims=:" %%i in ('type "%infile%" ^|findstr /n "^"') do (
if %%i lss %found% (
echo(%%j
) else if %%i equ %found% (
set "lastline=%%j"
setlocal enabledelayedexpansion
set "right=!lastline:*%search%=!"
call set "lastline=%%lastline:%search%!right!=%search%%%"
echo(!lastline!
endlocal
)
)>>"%outfile%"
endlocal
Code: Select all
@echo off
for /f "delims=:" %%a in ('findstr /n "End of Transfer" ^<test.txt') do set num=%%a
sed 1,%num%!d test.txt
pause
Code: Select all
@echo off
setlocal
set "file=test.txt"
type "%file%" | repl "(End of Transfer)(.*\n?)*" "$1" m >"%file%.mod"
move /q "%file%.mod" "%file%"
dbenham wrote:@foxidrive - I believe your sed solution will preserve trailing text after "End of Transfer" that appears on the same line. I imagine it would not be too difficult to truncate the line after "End of Transfer".
foxidrive wrote:dbenham wrote:@foxidrive - I believe your sed solution will preserve trailing text after "End of Transfer" that appears on the same line. I imagine it would not be too difficult to truncate the line after "End of Transfer".
Yes Dave, his last post said that he wanted all the text on the same line.
Code: Select all
@echo off
setlocal
set "file=test.txt"
type "%file%" | repl "(End of Transfer.*\n?)(.*\n?)*" "$1" m >"%file%.mod"
move /q "%file%.mod" "%file%"