1.

Solve : Batch code to find and replace strings in xml files and move them to new folder?

Answer» HI i need a BATCH CODE to find and replace the below two tasks(Task_RunOwt,Task_RunDbdIo)  if found with  another task(Task_RunGenericIo) in around 1500 xml files..is it possible???    The changed files should be moved to different folder after replacing the strings...

old tasks to be replaced:
1) Quote
<task>
      <uid>1T1I</uid>
      <name>Task_RunOwt</name>
      <params>
         <OrcIp>$ORC1IP$</OrcIp>
         <OrcUsername>$ORC1USERNAME$</OrcUsername>
         <OrcPassword>$ORC1PASSWORD$</OrcPassword>
         <VolumeNames>$VOLUME1NAME$,$VOLUME2NAME$</VolumeNames>
         <WriteToRawVolume>TRUE</WriteToRawVolume>
         <IoToolOptions>-b512 -n4194304 -o0 -t256 -c1 -r0 -l0 -w100 -s10 -p0 -g1 -v0 -d1 -z'' -q64 -f'' -i'' -U0</IoToolOptions>
      </params>
      <pass>1T3G</pass>
      <fail>abortfail</fail>
      <incomplete>abortfail</incomplete>
   </task>
2) Quote
<task>
      <uid>1T1I</uid>
      <name>Task_RunDbdIo</name>
      <params>
         <OrcIp>$ORC1IP$</OrcIp>
         <OrcUsername>$ORC1USERNAME$</OrcUsername>
         <OrcPassword>$ORC1PASSWORD$</OrcPassword>
         <VolumeNames>$VOLUME1NAME$,$VOLUME2NAME$</VolumeNames>
         <IOToolOptions>--queue 64 --seed --io_profile --trace STAT</IOToolOptions>
      </params>
      <pass>1T3G</pass>
      <fail>abortfail</fail>
      <incomplete>abortfail</incomplete>
   </task>
NEW Task Which has to be substituted in place of above two tasks if found in the xml files:
Quote
<task>
      <uid>1T1I</uid>
      <name>Task_RunGenericIo</name>
      <params>
         <GroupName>$GROUP1NAME$</GroupName>
         <ClusterName>$CLUSTER1NAME$</ClusterName>          
         <WriteToRawVolumeOrFile>raw</WriteToRawVolumeOrFile>
         <Client>
            <OrcIp>$ORC1IP$</OrcIp>
            <OrcUsername>$ORC1USERNAME$</OrcUsername>
            <OrcPassword>$ORC1PASSWORD$</OrcPassword>
            <Volume>
               <Names>$VOLUME1NAME$,$VOLUME2NAME$</Names>
            </Volume>
         </Client>
      </params>
      <pass>1T3G</pass>
      <fail>abortfail</fail>
      <incomplete>abortfail</incomplete>
   </task>

Points to be noted:
Quote
*uid,pass,fail and incomplete tags and its content in the xml code should remain unchanged,only the code in between the uid and pass tags should be replaced with following
*In RunOwt task,When WriteToRawVolume is mentioned true, in RungenericIo,WriteToRawVolumeOrFile should be= raw
*In RunOwt task,When WriteToRawVolume is mentioned FALSE, in RungenericIo,WriteToRawVolumeOrFile should be= file
*When RunDbdio task is found ,in RungenericIo,WriteToRawVolumeOrFile should always be =raw
*if only volume1name exists than only volume1name should be present(but not volume2name).
*IoToolOptions in above tasks is not required in RunGenericIo task.
*basically the xml code logic should be same after replacement


It would be of great help if this works out...Thanks in advance...Does it have to be in batch? I know repl.bat uses java script, and might be what you are looking for.
https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat

You'll have to ask Squashman or Foxidrive for more info on it, as I haven't used it much. Quote from: Venkat on June 28, 2014, 04:36:52 PM
Hi i need a BATCH CODE to find and replace the below two tasks(Task_RunOwt,Task_RunDbdIo)  if found with  another task(Task_RunGenericIo) in around 1500 xml files.

I have a few questions:

Will any xml file contain both Task_RunOwt and Task_RunDbdIo tasks?
Will any xml file contain more than one of the tasks?
Are all 1500 xml files in a single folder?
Hi Lemonilla,
Quote
Does it have to be in batch?

It is not mandatory to be in a batch , Any code is fine which makes the replacement of 2 tasks task in xml file to RunGenericIo Task.i ll check that link which u sent and let u no if it works.Hi Foxi,

Quote
Will any xml file contain both Task_RunOwt and Task_RunDbdIo tasks?
Will any xml file contain more than one of the tasks?
Are all 1500 xml files in a single folder?

1)I dont think any Xml file contains both the tasks Task_RunOwt and Task_RunDbdIo in a single XML File , But even if thats the scenario ,replacement has to be done with Task_RunGenericIo since other two tasks are deprecated.
2)Yup every Xml file has many different tasks which has Task_RunOwt and Task_RunDbdIo repeated no. of times or  only once.
3)All 1500 xml files are not in single folder,they are in different folders of same directory.
4)Task_RunOwt and Task_RunDbdIo tasks are deprecated in the tool i work with, so i need them get replaced with Task_RunGenericIo which is used for writing data in volumes of Client Orcs mentioned..


Quote
https://www.dropbox.com/s/qidqwztmetbvklt/repl.bat

You'll have to ask Squashman or Foxidrive for more info on it, as I haven't used it much.

Will this code help me out Foxi/SquashMan??? Is so pls tell me..


Discussion

No Comment Found