Refining Search Criteria
Posted: Tue May 22, 2012 4:29 pm
I am trying to remove some lines from group of text files using Find and Replace. I have approx. 6,000 of these files. The lines I am trying to remove are:
REM net use lpt1: \\abcprint\abfde012p
REM net use lpt2: \\efgprint\kub068p
REM net use lpt3: \\hklprint\abc????p
In the Search > Find in Files window I search for net use lpt This returns all the files with the entries I am looking to remove. I then select and open the files and then use the Search > Replace window, I enter .*[lpt]*p$ in the Find What field and leave the replace field blank so that it will remove the line.
My issue is that it is removing other lines that I do not want it to. For example it is removing:
rem net use y: \\abc\app
:: Check if on XenApp
cscript y:\update\printeradd.vbs /d \\abc\xyz025p
Here is an example of the text file:
@echo off
::::net time \\atl /set /y > nul
rem net use y: \\abc\app
Net Use U: \\ADCFS1\Users\test
:: Check if on XenApp
cscript y:\update\printeradd.vbs /d \\abc\xyz025p
cscript y:\update\printeradd.vbs \\abc\xyz027c
cscript y:\update\printeradd.vbs \\abc\xyz026m
REM net use lpt1: \\abcprint\abfde012p
REM net use lpt2: \\efgprint\kub068p
REM net use lpt3: \\hklprint\abc????p
C:\windows\lmscript.$$$
@echo on
I am sure that this is childsplay but my inner child has run away. What do I need to use in the Find What field to only select the lines containing the rem net use lpt variable? Any help would be greatly appreciated.
REM net use lpt1: \\abcprint\abfde012p
REM net use lpt2: \\efgprint\kub068p
REM net use lpt3: \\hklprint\abc????p
In the Search > Find in Files window I search for net use lpt This returns all the files with the entries I am looking to remove. I then select and open the files and then use the Search > Replace window, I enter .*[lpt]*p$ in the Find What field and leave the replace field blank so that it will remove the line.
My issue is that it is removing other lines that I do not want it to. For example it is removing:
rem net use y: \\abc\app
:: Check if on XenApp
cscript y:\update\printeradd.vbs /d \\abc\xyz025p
Here is an example of the text file:
@echo off
::::net time \\atl /set /y > nul
rem net use y: \\abc\app
Net Use U: \\ADCFS1\Users\test
:: Check if on XenApp
cscript y:\update\printeradd.vbs /d \\abc\xyz025p
cscript y:\update\printeradd.vbs \\abc\xyz027c
cscript y:\update\printeradd.vbs \\abc\xyz026m
REM net use lpt1: \\abcprint\abfde012p
REM net use lpt2: \\efgprint\kub068p
REM net use lpt3: \\hklprint\abc????p
C:\windows\lmscript.$$$
@echo on
I am sure that this is childsplay but my inner child has run away. What do I need to use in the Find What field to only select the lines containing the rem net use lpt variable? Any help would be greatly appreciated.