Using the MPR to REPLACE Text in Files

Moderator: MVogt

Post Reply
User avatar
Theo_Gottwald
Posts: 367
Joined: 03. Oct 2009, 08:57
Location: Herrenstr.11 * 76706 Dettenheim
Contact:

Using the MPR to REPLACE Text in Files

Post by Theo_Gottwald » 08. May 2018, 09:51

Let's say there is a file that is created on a client - for example, as an export from the registry.
Now we want to replace certain things in the file. In this case we wat to REPLACE:

Code: Select all

Old="\\\\server1-9999\\Configurator$" mit dem String:
with:
NEW="\\\\%EmpirumServer%\\Configurator$"
I recommend using a 4 rower with the Matrix42 Package Robot and the RIF\ "Replace-in-File" command.
The example shows the use of variables in the MPR.

Code: Select all

VAR\$$PAT=C:\Myfile.reg
VAR\$$OLD=\\\\server1-9999\\Configurator$
VAR\$$NEW=\\\\%EmpirumServer%\\Configurator$
RIF\$$PAT|$$OLD|$$NEW
END\
And the re-import into the registry?
That is just a one-liner:

Code: Select all

' Import File into Registry
REG\$$PAT
This works in text or script files of all kinds.

Here's an example of a "quotes remover". All "are replaced by $sp$ (means spaces).

Code: Select all

' $ev4$ is the path where the compiled EXE is located.
VAR\$$PAT=$ev4$
' The NFF\ command looks for files with this specification in the specified path
NFF\$$PAT|*.txt
   MBX\I could not find an ".txt" File!$crlf$Script ends.
   GOTO enx
EFF\
' Here we do the REPLACE
VAR\$$FIL=$v1$
RIF\$$FIL|"|$sp$
@

Post Reply

Return to “Package Robot”

Who is online

Users browsing this forum: No registered users and 3 guests