Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Batch code to find and replace strings in xml files and move them to new folder  (Read 5980 times)

0 Members and 1 Guest are viewing this topic.

Venkat

    Topic Starter


    Rookie

    • Experience: Experienced
    • OS: Windows 7
    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???  :o :o  ::) :-\ 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...

    Lemonilla



      Apprentice

    • "Too sweet"
    • Thanked: 70
    • Computer: Specs
    • Experience: Experienced
    • OS: Windows 7
    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: patio
    God Bless the DOS Helpers...
    Quote
    If it compiles, send the files.

    foxidrive



      Specialist
    • Thanked: 268
    • Experience: Experienced
    • OS: Windows 8
    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?

    Venkat

      Topic Starter


      Rookie

      • Experience: Experienced
      • OS: Windows 7
      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.

      Venkat

        Topic Starter


        Rookie

        • Experience: Experienced
        • OS: Windows 7
        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..
        « Last Edit: June 28, 2014, 10:03:30 PM by Venkat »