Using the MPR to REPLACE Text in Files

Moderator: MVogt

Antworten
Benutzeravatar
Theo_Gottwald
Beiträge: 309
Registriert: 03. Okt 2009, 08:57
Wohnort: Herrenstr.11 * 76706 Dettenheim
Kontaktdaten:

Using the MPR to REPLACE Text in Files

Beitrag von Theo_Gottwald » 08. Mai 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: Alles auswählen

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: Alles auswählen

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: Alles auswählen

' 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: Alles auswählen

' $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$
@

Antworten

Zurück zu „Package Robot“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast