Find and Replace complex

August 12, 2009 at 09:50:16
Specs: Windows XP
Hi, i tried searching for hours and have seen this bought up a few times on this forum however the responses don't exactly help me, as for what i need done, or if they do don't explain how to implement them to my needs.

Anyway, i need the following done:

Firstly, i will request the user to input the wanted file name with set /p Mapname=Enter name here:

Then i will need to implement it into this file:

BOLD objects are reference

<Archive Name="MyTestMap" DefaultCompression="Buffer" DefaultRoot="ROOT" ArchiveFile="Mods\%Mymap%.sga">
<IncludeRule Extensions="dds,camp,info,scar,scenario,scenariomarker,xml,api,scar,lua,nis,atmospherepreset" MinSize="-1" MaxSize="-1" />
<CompressionRule Extensions="dds,camp,info,scar,scenario,scenariomarker,xml,api,scar,lua,nis,atmospherepreset" MinSize="-1" MaxSize="-1" CompressionType="Stream" />
<TOC Name="Art" Alias="DATA" RelativeRoot="Data\" />
<Directory Name="Data\MAPS" />


The ROOT section has to be replaced with a path no matter where they installed the required app.
Default is "C:\Program Files\Steam\SteamApps\common\BnZ\

So Root, or whatever is already inbetween the two " " needs to be replaced with the root directory.

I request this because i always see apps or batch files that seem to know where a program is installed no matter where it is. i.e Default is C:\Program files\Hello , however the user really installed it on D:\Files\Help\Coding


%Mymap% needs to be replaced with the Users input
e.g Koala.

However, assuming something different is there i need it to replace once again what ever is inside the quote marks " "

But only replace that part, and ensure the .sga is still there.

Hope i made sense.

Hope what needs to be done can be done.

Prior thanks for any help. ill keep my eyes peeled.

See More: Find and Replace complex

Report •

August 12, 2009 at 12:07:53
At a minium, i could do the following:

This would be a pre-edited file with %Mymap% in the file as %Mymap% and with the ROOT preset as the default (hoping they install there)

anyway, the process would be:

(copy)Move Edited File to arch Folder
(copy \arch\backup)Create Backup and place in arch\backup

run batch to replace %Mymap%.sga on the file in \arch folder

(del)delete files in \arch folder after execution.

copy + move arch\backup file to \arch folder

So basically i will have a template.

So with that said, at miniumum i will need:

a. A script that takes the userinput

(set /p Mapname=Enter name here:)

and puts it between the double quotes (" ") in the file.

This is probably the easiest method to do it. even though i have looked at countless related articles i don't understand token or other commands suggested so im unable to adapt my code to theirs.

End result

in the file, %Mymap% = X
X = the users input.

Thanks ahead.

Report •
Related Solutions

Ask Question