2
How to remove everything after the first word on each line in a text file containing the character pipe
?
It works for removing simple/common characters, but has not worked to remove the character | ( pipe
) of the text file.
blue | a
[email protected]:pass | a
fear under dark | a
123 | a
abc 123 | a
hustlerman | a
yellow | a
123 | a
[email protected]:senha | a
[email protected]:guypassord | a
12345678-king-man | a
rabaman | a
abc | a
I’m using the following code:
setlocal enableextensions disabledelayedexpansion
set /p txtfile=Text File Name:
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:
Thanks, sorry for the delay, it helped a lot!
– Sérgio Wilker
Trankilo Tê!! No peacock!! Thank you!
– It Wasn't Me