Hello every one,
I am veryu new to batch programming. I have a requirement where i need to find a string in an text file and then replace it with my value. the string is something like
<propname name="Group.duration></propname>
now i want to search this particilar string and replace it with
<propname name="Group.duration>30</propname>
please help me as I dont know how to proceed
regards,
Shekhar
Find and replace batch file
Moderator: DosItHelp
Re: Find and replace batch file
Here is one possible script. I have assumed that your input file is at C:/xyz.xml.
Save the script in file C:/Scripts/FAR.txt. Script is in biterscripting. Start the script, and run this command.
The value() ("30" in this case) will be placed between two marker tags in file C:/xyz.xml. To run this automatically periodically, just schedule this command with cron or scheduler.
Code: Select all
# Script FAR.txt
var str content, value
cat "C:/xyz.xml" > $content
sal -r -c "^<propname name=\"Group.duration\>&</propname\>^" ("^<propname name=\"Group.duration\>"+$value+"</propname\>^") $content > null
echo $content > "C:/xyz.xml"
Save the script in file C:/Scripts/FAR.txt. Script is in biterscripting. Start the script, and run this command.
Code: Select all
script "C:/Scripts/FAR.txt" value("30")
The value() ("30" in this case) will be placed between two marker tags in file C:/xyz.xml. To run this automatically periodically, just schedule this command with cron or scheduler.
Code: Select all
"C:/biterscripting/biterscripting.exe" "C:/Scripts/FAR.txt" value("30")