Hi. dumby tn here wanting to learn summet which I thought would be easy but I just keep getting it wrong. I have a .txt file with lots of entries in and I want to delete all instances of a certain text. I can not even get the basics down. For example I have a .txt file with RED CAR BLUE CAR GREEN CAR I don't want the word CAR in my list, but say CAR appears 20 times or more and I am too lazy to manually delete it. I have tried commands, powershell, even next doors dog, but he's just barking mad. I just can not get the hang of it.. Please help. It must be easy, right ?
Why Mr.X you suggestion works well. I have just downloaded notepad++. Was not sure on how to do but I made a simple text file to test on, opened it up, searched for the text I did not want. Chose "replace" but left the replace tab empty. text went away. how cool. I think I will have to test this out on my file I want to amend..
If you also want the newlines to be gone after replacing (as not to create empty lines), do the following in Notepad++ or your favorite editor with regex support: Open the replace text window In the section 'Search Mode' left below Select the option 'Extended' In 'Find what' write your to remove text, but end it with '\r\n' Code: i.stack.imgur.com/r22P5.png A '\r' is a control character for 'carriage return' and '\n' for 'line break', combining them for newline or so called 'CRLF'. After done, i recommend to set 'Search Mode' back to 'Normal' to not confuse later if you need to replace a literal '\r\n'. Have a nice day ^^.
Thanks for that info. Once I had removed the text I did not want I just used the notepad++ to remove all empty lines. A little bit of manual work but by god it works a treat.
1) Code: type yourtext.txt | find /i /v "Line you want to exclude" > cleared_yourtext.txt 2) Code: find /i /v "Line you want to exclude" "X:\Path\yourtext.txt" > cleared_yourtext.txt
Good code KNARZ. I think findstr command is better than find. I used findstr command like bellow. @echo off ren "About Me.txt" About_Me.txt findstr /v /i /c:"Car" /c:"Red" About_Me.txt >"About Me.txt" del About_Me.txt The command above will recreate the file deleting the line with Car and Red.