|
Answer» Hi,
I am new to world of scripting, i need your expert help to execute a task for which i need a script.
Task: I have a sample XML file, in which i need to replace a value (oldString) with (newString) and Save it as (filename). I have excel SHEET with values (newString) & (filename).
I need to extract (newString) value from excelsheet, replace it in Sample XML file and Save it as (filename). I need to do this for all values (in different rows) in excel sheet.
Please help me with Batch Script for same. OS: Windows 7 CMD version: 6.1.7601If you show sample data then you stand a better chance of getting what you need.You cannot do this with only cmd. you will have to find some other external program to CALL to GET your newValues from the spreadsheet. If you post te xml file we MAY be able to help with that part.Thanks for showing your interest.
I am attaching files - SampleXML.txt & Source.txt
Task summary: SampleXML.txt file has a value "oldString" which need to be replaced by value "newString" and this file need to be Saved as "filename.xml"
- SampleXML.txt file is used as REFERENCE having value "oldString" - Source.txt is having 10 values of "newString" & "filename"
End result would be = there will be 10 files generated viz filename1.xml to filename10.xml
[recovering disk space, attachment deleted by admin]This uses a helper batch file called repl.bat from - http://www.dostips.com/forum/viewtopic.php?f=3&t=3855
It is a little more complicated because your source.txt has Unix line endings. If you use MSDOS files then it only needs the middle block of code.
Code: [Select]@echo off :: convert hex 0d to hex 0d0a to give msdos line endings type "Source.txt"|repl "\x0d" "\r\n" x >tmp.tmp
for /f "usebackq tokens=1,* delims=," %%a in ("tmp.tmp") do ( type "SampleXML.txt"|repl "oldString" "%%a" m >"%%b.xml" )
del tmp.tmp
|