Search and replace variables!

General discussions about Advanced Find and Replace
Post Reply
Stiffbag
Posts: 12
Joined: Tue Feb 01, 2005 7:11 pm

Search and replace variables!

Post by Stiffbag »

Hi,

I am evaluating your product and I am not able to make it work properly.

Here is a sample of what I need:

Search:

net use (drive letter): \\(servername) : some other text after

Replace with:

net use (same drive letter): \\(different servername) : same texte after

I need to keep the drive letter (because it could be different) and the texte after the new server name. So, basically, I need to search for that whole string but change the server name only.

Thanks in advance for your help.

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

Go to Batch replace, check on "Use regular expressions"

Put Search for:
(\w+:\\\\)oldname(:\w+)

Replace with:
$1newname$2

where is oldname is old name of the server.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

Stiffbag
Posts: 12
Joined: Tue Feb 01, 2005 7:11 pm

Post by Stiffbag »

Thanks for the prompt reply. I have tried your solution but it did not work. Here is a portion of the script. Maybe that will help.

:: Map Network Drives

Net Use G: \\server1\Custom > NUL
Net Use H: \\server2\Apps > NUL
Net Use I: \\server3\Images > NUL
Net Use J: \\server4\Share$ > NUL
Net Use K: \\server3\Baseline > NUL
Net Use L: \\server3\Division > NUL
Net Use x: \\server5\Personnal > nul

But in the script I have historical info that I need to keep.

:: PC Information For software rollout
:: IF NOT EXIST C:\WTSRV %DCROOT%\utils\info w=80 o=\\server3\info$\clients

So how can I change server3 to serverX and keep the text before and after but without changing the historical info?

Hope I was clearer.

Abacre
Site Admin
Posts: 1223
Joined: Mon Jan 31, 2005 5:32 pm

Post by Abacre »

Stiffbag wrote:Thanks for the prompt reply. I have tried your solution but it did not work.

Because you said it's :\\servername : in your source text.

Well in this case it could be done even without regular expressions.
Because you have very formal string:
:space\\servername\

So disable "Use regular expressions"

Then enter Search for:
: \\server3\

Replace with:
: \\serverX\

It will work.

But it should be done in plenty of other ways too.
For example if you want to make a connection with "Net Use" text
you may use the following pair (enable "Use regular expressions" for
this case):

Search for:
Net Use (\w): \\\\server3\\

Replace with:
Net Use $1: \\\\serverX\\

I verified it works too.
Kind regards,
Abacre Limited
http://www.abacre.com
support@abacre.com

Stiffbag
Posts: 12
Joined: Tue Feb 01, 2005 7:11 pm

Post by Stiffbag »

Thank you it woked like a charm. :lol:

Post Reply