Page 1 of 1

Search and replace variables!

Posted: Tue Feb 01, 2005 10:49 pm
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.

Posted: Wed Feb 02, 2005 7:52 am
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.

Posted: Wed Feb 02, 2005 6:09 pm
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.

Posted: Wed Feb 02, 2005 7:05 pm
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.

Posted: Wed Feb 02, 2005 10:02 pm
by Stiffbag
Thank you it woked like a charm. :lol: