I recently needed to find a quick way to have a .cmd check for "specific string" in a .reg file, and delete that string and save new .reg file. This .cmd or .bat can be used to "Delete" specific line from .txt; .reg; .ini; etc. Example .cmd so, save the code as anyname.cmd:- BLUE=name of file to be checked RED=line of text to delete GREEN=name of file to save Code: @echo off Type Test.txt | findstr /I /V /C:"So, lets remove this line" >>Test2.txt exit Example Test.txt save this code as Test.txt:- Code: Example of using a .cmd file to remove a line of text:- Have a nice day. To err is human, but to forgive is divine. So, lets remove this line from this text as an example We will save edited text, minus the above line. now run the "anyname.cmd" while its sitting next to the "Test.txt"; and a new file named "Test2.txt" will be produced ... minus the "highlighted" line.
On with a small project which seems to be growing by the second. I download,ohhh quite some time ago now a "List Maker" app. It works well but,well thought I could make a simple .cmd to do the job. Did a bit of surfing and found the simple command to make a list of files in the current directory. But this added two lines into the newly made list i did not want. the .cmd file and the .txt file it's self.. Did a bit more searching on how to delete a line from a .txt file and found this. Worked well. But..... I wanted to remove two lines but can not seem to write the right code.... I got this.. Then elaberated a bit to this i was wondering what is the right way to remove two different lines of text from a .txt and could my code be cleaned up ? Cheers... ohhh yess... What about adding extra to a certain line in the .txt doc...Can that be done. i.e in a text doc there is the line "Old Mc Donald" can you via a .cmd make this into "Old McDonald Had A farm" ( first thing which came into my head )
could you please tell me how to do so but save the output in the same file , i dont want to save it in other file
You can use nename command first. For example: list.txt is your original file. So you use rename list.txt list_old.txt command first. Then you will be able to save your edited file as list.txt.