I would like to remove everything after the first word in each line of this text document. It works for simple character removal, but does not work when I try to remove the "|" of the text file.
I'mtryingtousethefollowingcode:
setlocalenableextensionsdisabledelayedexpansionset/ptxtfile=TextFileName:Echo.set/p"search=Search for: "
Echo.
set /p "replace=Replace to: "
for /f "delims=" %%i in ('type "%txtfile%.txt" ^& break ^> "%txtfile%.txt" ') do (
set "line=%%i"
setlocal enabledelayedexpansion
>>"%txtfile%.tmp" echo(!line:%search%=%replace%!
endlocal
)
ren "%txtfile%".tmp "%txtfile%".txt
pause
Error: