Batch looping through directory find all XML and replace a certain (unknown) value with another (known) value












1















Just a question, I don't know if this is possible but let me explain it by example.



XML (containing several values)



<WORKFLOW DESCRIPTION ="" ISENABLED ="YES" ISRUNNABLESERVICE ="NO" ISSERVICE ="NO" ISVALID ="YES" NAME ="DIMENSIONS" REUSABLE_SCHEDULER ="NO" SCHEDULERNAME ="Scheduler" SERVERNAME ="SERVER_NAME_DUMMY" SERVER_DOMAINNAME ="Domain_DUMMY" SUSPEND_ON_ERROR ="NO" TASKS_MUST_RUN_ON_SERVER ="NO" VERSIONNUMBER ="1">


I want to be able to catch with findstr (unless there is a better way) SERVERNAME = (this occurs only once in the whole document) and replace the value of it by SERVER_NAME_PROPER to get the following result:



SERVERNAME ="SERVER_NAME_PROPER".



The problem is I don't know the value of SERVERNAME so i cant strictly search on SERVER_NAME_DUMMY (i don't know the length either, i saw string manipulation by character sets). Also the lines just continues with other values and elements after it (no end line manipulation). Maybe it is wise to search for SERVERNAME =(promt value) and stop before SERVERDOMAIN_NAME. Because the value is after SERVERNAME= "VALUE" and before SERVERDOMAIN_NAME.



I know that after SERVERNAME = the value needs to be replaced by my hardcoded value. If i can preform this then i can make in batch a FOR command to loop all files in the whole directory and preform this certain command.










share|improve this question

























  • By the way, welcome to Stack Overflow! If my answer below was helpful, please consider marking it as accepted. See this page for an explanation of why this is important.

    – rojo
    Apr 10 '15 at 14:46
















1















Just a question, I don't know if this is possible but let me explain it by example.



XML (containing several values)



<WORKFLOW DESCRIPTION ="" ISENABLED ="YES" ISRUNNABLESERVICE ="NO" ISSERVICE ="NO" ISVALID ="YES" NAME ="DIMENSIONS" REUSABLE_SCHEDULER ="NO" SCHEDULERNAME ="Scheduler" SERVERNAME ="SERVER_NAME_DUMMY" SERVER_DOMAINNAME ="Domain_DUMMY" SUSPEND_ON_ERROR ="NO" TASKS_MUST_RUN_ON_SERVER ="NO" VERSIONNUMBER ="1">


I want to be able to catch with findstr (unless there is a better way) SERVERNAME = (this occurs only once in the whole document) and replace the value of it by SERVER_NAME_PROPER to get the following result:



SERVERNAME ="SERVER_NAME_PROPER".



The problem is I don't know the value of SERVERNAME so i cant strictly search on SERVER_NAME_DUMMY (i don't know the length either, i saw string manipulation by character sets). Also the lines just continues with other values and elements after it (no end line manipulation). Maybe it is wise to search for SERVERNAME =(promt value) and stop before SERVERDOMAIN_NAME. Because the value is after SERVERNAME= "VALUE" and before SERVERDOMAIN_NAME.



I know that after SERVERNAME = the value needs to be replaced by my hardcoded value. If i can preform this then i can make in batch a FOR command to loop all files in the whole directory and preform this certain command.










share|improve this question

























  • By the way, welcome to Stack Overflow! If my answer below was helpful, please consider marking it as accepted. See this page for an explanation of why this is important.

    – rojo
    Apr 10 '15 at 14:46














1












1








1








Just a question, I don't know if this is possible but let me explain it by example.



XML (containing several values)



<WORKFLOW DESCRIPTION ="" ISENABLED ="YES" ISRUNNABLESERVICE ="NO" ISSERVICE ="NO" ISVALID ="YES" NAME ="DIMENSIONS" REUSABLE_SCHEDULER ="NO" SCHEDULERNAME ="Scheduler" SERVERNAME ="SERVER_NAME_DUMMY" SERVER_DOMAINNAME ="Domain_DUMMY" SUSPEND_ON_ERROR ="NO" TASKS_MUST_RUN_ON_SERVER ="NO" VERSIONNUMBER ="1">


I want to be able to catch with findstr (unless there is a better way) SERVERNAME = (this occurs only once in the whole document) and replace the value of it by SERVER_NAME_PROPER to get the following result:



SERVERNAME ="SERVER_NAME_PROPER".



The problem is I don't know the value of SERVERNAME so i cant strictly search on SERVER_NAME_DUMMY (i don't know the length either, i saw string manipulation by character sets). Also the lines just continues with other values and elements after it (no end line manipulation). Maybe it is wise to search for SERVERNAME =(promt value) and stop before SERVERDOMAIN_NAME. Because the value is after SERVERNAME= "VALUE" and before SERVERDOMAIN_NAME.



I know that after SERVERNAME = the value needs to be replaced by my hardcoded value. If i can preform this then i can make in batch a FOR command to loop all files in the whole directory and preform this certain command.










share|improve this question
















Just a question, I don't know if this is possible but let me explain it by example.



XML (containing several values)



<WORKFLOW DESCRIPTION ="" ISENABLED ="YES" ISRUNNABLESERVICE ="NO" ISSERVICE ="NO" ISVALID ="YES" NAME ="DIMENSIONS" REUSABLE_SCHEDULER ="NO" SCHEDULERNAME ="Scheduler" SERVERNAME ="SERVER_NAME_DUMMY" SERVER_DOMAINNAME ="Domain_DUMMY" SUSPEND_ON_ERROR ="NO" TASKS_MUST_RUN_ON_SERVER ="NO" VERSIONNUMBER ="1">


I want to be able to catch with findstr (unless there is a better way) SERVERNAME = (this occurs only once in the whole document) and replace the value of it by SERVER_NAME_PROPER to get the following result:



SERVERNAME ="SERVER_NAME_PROPER".



The problem is I don't know the value of SERVERNAME so i cant strictly search on SERVER_NAME_DUMMY (i don't know the length either, i saw string manipulation by character sets). Also the lines just continues with other values and elements after it (no end line manipulation). Maybe it is wise to search for SERVERNAME =(promt value) and stop before SERVERDOMAIN_NAME. Because the value is after SERVERNAME= "VALUE" and before SERVERDOMAIN_NAME.



I know that after SERVERNAME = the value needs to be replaced by my hardcoded value. If i can preform this then i can make in batch a FOR command to loop all files in the whole directory and preform this certain command.







xml batch-file cmd findstr






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 13 '18 at 9:13









Cœur

17.6k9105145




17.6k9105145










asked Apr 9 '15 at 6:48









H. H. ShabastariH. H. Shabastari

162




162













  • By the way, welcome to Stack Overflow! If my answer below was helpful, please consider marking it as accepted. See this page for an explanation of why this is important.

    – rojo
    Apr 10 '15 at 14:46



















  • By the way, welcome to Stack Overflow! If my answer below was helpful, please consider marking it as accepted. See this page for an explanation of why this is important.

    – rojo
    Apr 10 '15 at 14:46

















By the way, welcome to Stack Overflow! If my answer below was helpful, please consider marking it as accepted. See this page for an explanation of why this is important.

– rojo
Apr 10 '15 at 14:46





By the way, welcome to Stack Overflow! If my answer below was helpful, please consider marking it as accepted. See this page for an explanation of why this is important.

– rojo
Apr 10 '15 at 14:46












2 Answers
2






active

oldest

votes


















1














Whenever you work with HTML or XML, it's always best to parse it as HTML or XML, rather than trying to scrape and hack it as text. That way, as long as it's valid markup, you are not so dependent upon formatting.



For working with XML, you can use the Microsoft.XMLDOM COM object with Windows Script Host fairly intuitively (or at least hopefully you can follow the logic in my demonstration below). Here's a hybrid batch + JScript solution. Save it with a .bat extension and salt to taste.





@if (@CodeSection == @Batch) @then

@echo off
setlocal

set "attribute=SERVERNAME"
set "new_value=This works."

for %%I in (*.xml) do (
rem // invoke JScript for each XML file
cscript /nologo /e:JScript "%~f0" "%%~I" "%attribute%" "%new_value%"
)

rem // end main runtime
goto :EOF

@end // end batch / begin JScript chimera

var DOM = WSH.CreateObject('Microsoft.XMLDOM'),
args = { file: WSH.Arguments(0), attr: WSH.Arguments(1), val: WSH.Arguments(2) };

DOM.load(args.file);
DOM.async = false;
DOM.setProperty('SelectionLanguage', 'XPath');

if (DOM.parseError.errorCode) {
WSH.Echo(DOM.parseError.reason);
WSH.Quit(1);
}

for (var d = DOM.selectNodes('//*[@' + args.attr + ']'), i = 0; i < d.length; i++)
d[i].setAttribute(args.attr, args.val);

DOM.save(args.file);





share|improve this answer

































    0














    I posted a Replace script here 2 days ago If text string contains certain words, wrap those words in a span tag.



    Findstr



    "^(SERVERNAME=x22^)^([a-z]+^)^(x22^)"


    Replace with



    $1WHATEVERYOUWANT$3


    $1 is first set brackets, $2 second, and $3 third. Above carets are escaping it for CMD - it looks like this after parsing (SERVERNAME=")([a-z]+)(")






    share|improve this answer


























    • Serenity thank you for your post but i can't seem to get it working?

      – H. H. Shabastari
      Apr 9 '15 at 7:58











    • $1 contains Servername=", $2 contains the actual servername alpha only, if using underscore for real, change [a-z] to [a-z_]. I am only specifing lower case as I expect you would run it with ignore case option. Also as that code is lifted from a file of similar functions you need to remove the lines Sub ReplaceCmd and End Sub. Then cscript //nologo "C:path to scriptscript.vbs" "" i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" < "c:filetoprocess.txt" > Outputfile.txt.

      – Serenity
      Apr 9 '15 at 8:17











    • skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121 is where you can download filter0.8.zip as a file easy to use. Then Filter replace i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" "$1YourServerName$3" < csv.txt > output.txt. Filter has 19 text file functions and many options and is sample code for vbs processing of text files. Showing how easy it is.

      – Serenity
      Apr 9 '15 at 8:20













    • Serenity,I don't know what is going on. You want me to create a vbs script? I am not getting howto parse this and replace the value with a hardcoded value. Can you please paste the script to change the value after findstr? I am sorry to not understand this:(

      – H. H. Shabastari
      Apr 9 '15 at 8:23













    • You can't use findstr. It doesn't do replace. If you want a replace program you have to make your own.

      – Serenity
      Apr 9 '15 at 8:25













    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29531621%2fbatch-looping-through-directory-find-all-xml-and-replace-a-certain-unknown-val%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    1














    Whenever you work with HTML or XML, it's always best to parse it as HTML or XML, rather than trying to scrape and hack it as text. That way, as long as it's valid markup, you are not so dependent upon formatting.



    For working with XML, you can use the Microsoft.XMLDOM COM object with Windows Script Host fairly intuitively (or at least hopefully you can follow the logic in my demonstration below). Here's a hybrid batch + JScript solution. Save it with a .bat extension and salt to taste.





    @if (@CodeSection == @Batch) @then

    @echo off
    setlocal

    set "attribute=SERVERNAME"
    set "new_value=This works."

    for %%I in (*.xml) do (
    rem // invoke JScript for each XML file
    cscript /nologo /e:JScript "%~f0" "%%~I" "%attribute%" "%new_value%"
    )

    rem // end main runtime
    goto :EOF

    @end // end batch / begin JScript chimera

    var DOM = WSH.CreateObject('Microsoft.XMLDOM'),
    args = { file: WSH.Arguments(0), attr: WSH.Arguments(1), val: WSH.Arguments(2) };

    DOM.load(args.file);
    DOM.async = false;
    DOM.setProperty('SelectionLanguage', 'XPath');

    if (DOM.parseError.errorCode) {
    WSH.Echo(DOM.parseError.reason);
    WSH.Quit(1);
    }

    for (var d = DOM.selectNodes('//*[@' + args.attr + ']'), i = 0; i < d.length; i++)
    d[i].setAttribute(args.attr, args.val);

    DOM.save(args.file);





    share|improve this answer






























      1














      Whenever you work with HTML or XML, it's always best to parse it as HTML or XML, rather than trying to scrape and hack it as text. That way, as long as it's valid markup, you are not so dependent upon formatting.



      For working with XML, you can use the Microsoft.XMLDOM COM object with Windows Script Host fairly intuitively (or at least hopefully you can follow the logic in my demonstration below). Here's a hybrid batch + JScript solution. Save it with a .bat extension and salt to taste.





      @if (@CodeSection == @Batch) @then

      @echo off
      setlocal

      set "attribute=SERVERNAME"
      set "new_value=This works."

      for %%I in (*.xml) do (
      rem // invoke JScript for each XML file
      cscript /nologo /e:JScript "%~f0" "%%~I" "%attribute%" "%new_value%"
      )

      rem // end main runtime
      goto :EOF

      @end // end batch / begin JScript chimera

      var DOM = WSH.CreateObject('Microsoft.XMLDOM'),
      args = { file: WSH.Arguments(0), attr: WSH.Arguments(1), val: WSH.Arguments(2) };

      DOM.load(args.file);
      DOM.async = false;
      DOM.setProperty('SelectionLanguage', 'XPath');

      if (DOM.parseError.errorCode) {
      WSH.Echo(DOM.parseError.reason);
      WSH.Quit(1);
      }

      for (var d = DOM.selectNodes('//*[@' + args.attr + ']'), i = 0; i < d.length; i++)
      d[i].setAttribute(args.attr, args.val);

      DOM.save(args.file);





      share|improve this answer




























        1












        1








        1







        Whenever you work with HTML or XML, it's always best to parse it as HTML or XML, rather than trying to scrape and hack it as text. That way, as long as it's valid markup, you are not so dependent upon formatting.



        For working with XML, you can use the Microsoft.XMLDOM COM object with Windows Script Host fairly intuitively (or at least hopefully you can follow the logic in my demonstration below). Here's a hybrid batch + JScript solution. Save it with a .bat extension and salt to taste.





        @if (@CodeSection == @Batch) @then

        @echo off
        setlocal

        set "attribute=SERVERNAME"
        set "new_value=This works."

        for %%I in (*.xml) do (
        rem // invoke JScript for each XML file
        cscript /nologo /e:JScript "%~f0" "%%~I" "%attribute%" "%new_value%"
        )

        rem // end main runtime
        goto :EOF

        @end // end batch / begin JScript chimera

        var DOM = WSH.CreateObject('Microsoft.XMLDOM'),
        args = { file: WSH.Arguments(0), attr: WSH.Arguments(1), val: WSH.Arguments(2) };

        DOM.load(args.file);
        DOM.async = false;
        DOM.setProperty('SelectionLanguage', 'XPath');

        if (DOM.parseError.errorCode) {
        WSH.Echo(DOM.parseError.reason);
        WSH.Quit(1);
        }

        for (var d = DOM.selectNodes('//*[@' + args.attr + ']'), i = 0; i < d.length; i++)
        d[i].setAttribute(args.attr, args.val);

        DOM.save(args.file);





        share|improve this answer















        Whenever you work with HTML or XML, it's always best to parse it as HTML or XML, rather than trying to scrape and hack it as text. That way, as long as it's valid markup, you are not so dependent upon formatting.



        For working with XML, you can use the Microsoft.XMLDOM COM object with Windows Script Host fairly intuitively (or at least hopefully you can follow the logic in my demonstration below). Here's a hybrid batch + JScript solution. Save it with a .bat extension and salt to taste.





        @if (@CodeSection == @Batch) @then

        @echo off
        setlocal

        set "attribute=SERVERNAME"
        set "new_value=This works."

        for %%I in (*.xml) do (
        rem // invoke JScript for each XML file
        cscript /nologo /e:JScript "%~f0" "%%~I" "%attribute%" "%new_value%"
        )

        rem // end main runtime
        goto :EOF

        @end // end batch / begin JScript chimera

        var DOM = WSH.CreateObject('Microsoft.XMLDOM'),
        args = { file: WSH.Arguments(0), attr: WSH.Arguments(1), val: WSH.Arguments(2) };

        DOM.load(args.file);
        DOM.async = false;
        DOM.setProperty('SelectionLanguage', 'XPath');

        if (DOM.parseError.errorCode) {
        WSH.Echo(DOM.parseError.reason);
        WSH.Quit(1);
        }

        for (var d = DOM.selectNodes('//*[@' + args.attr + ']'), i = 0; i < d.length; i++)
        d[i].setAttribute(args.attr, args.val);

        DOM.save(args.file);






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Apr 10 '15 at 16:40

























        answered Apr 9 '15 at 15:40









        rojorojo

        19.4k43572




        19.4k43572

























            0














            I posted a Replace script here 2 days ago If text string contains certain words, wrap those words in a span tag.



            Findstr



            "^(SERVERNAME=x22^)^([a-z]+^)^(x22^)"


            Replace with



            $1WHATEVERYOUWANT$3


            $1 is first set brackets, $2 second, and $3 third. Above carets are escaping it for CMD - it looks like this after parsing (SERVERNAME=")([a-z]+)(")






            share|improve this answer


























            • Serenity thank you for your post but i can't seem to get it working?

              – H. H. Shabastari
              Apr 9 '15 at 7:58











            • $1 contains Servername=", $2 contains the actual servername alpha only, if using underscore for real, change [a-z] to [a-z_]. I am only specifing lower case as I expect you would run it with ignore case option. Also as that code is lifted from a file of similar functions you need to remove the lines Sub ReplaceCmd and End Sub. Then cscript //nologo "C:path to scriptscript.vbs" "" i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" < "c:filetoprocess.txt" > Outputfile.txt.

              – Serenity
              Apr 9 '15 at 8:17











            • skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121 is where you can download filter0.8.zip as a file easy to use. Then Filter replace i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" "$1YourServerName$3" < csv.txt > output.txt. Filter has 19 text file functions and many options and is sample code for vbs processing of text files. Showing how easy it is.

              – Serenity
              Apr 9 '15 at 8:20













            • Serenity,I don't know what is going on. You want me to create a vbs script? I am not getting howto parse this and replace the value with a hardcoded value. Can you please paste the script to change the value after findstr? I am sorry to not understand this:(

              – H. H. Shabastari
              Apr 9 '15 at 8:23













            • You can't use findstr. It doesn't do replace. If you want a replace program you have to make your own.

              – Serenity
              Apr 9 '15 at 8:25


















            0














            I posted a Replace script here 2 days ago If text string contains certain words, wrap those words in a span tag.



            Findstr



            "^(SERVERNAME=x22^)^([a-z]+^)^(x22^)"


            Replace with



            $1WHATEVERYOUWANT$3


            $1 is first set brackets, $2 second, and $3 third. Above carets are escaping it for CMD - it looks like this after parsing (SERVERNAME=")([a-z]+)(")






            share|improve this answer


























            • Serenity thank you for your post but i can't seem to get it working?

              – H. H. Shabastari
              Apr 9 '15 at 7:58











            • $1 contains Servername=", $2 contains the actual servername alpha only, if using underscore for real, change [a-z] to [a-z_]. I am only specifing lower case as I expect you would run it with ignore case option. Also as that code is lifted from a file of similar functions you need to remove the lines Sub ReplaceCmd and End Sub. Then cscript //nologo "C:path to scriptscript.vbs" "" i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" < "c:filetoprocess.txt" > Outputfile.txt.

              – Serenity
              Apr 9 '15 at 8:17











            • skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121 is where you can download filter0.8.zip as a file easy to use. Then Filter replace i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" "$1YourServerName$3" < csv.txt > output.txt. Filter has 19 text file functions and many options and is sample code for vbs processing of text files. Showing how easy it is.

              – Serenity
              Apr 9 '15 at 8:20













            • Serenity,I don't know what is going on. You want me to create a vbs script? I am not getting howto parse this and replace the value with a hardcoded value. Can you please paste the script to change the value after findstr? I am sorry to not understand this:(

              – H. H. Shabastari
              Apr 9 '15 at 8:23













            • You can't use findstr. It doesn't do replace. If you want a replace program you have to make your own.

              – Serenity
              Apr 9 '15 at 8:25
















            0












            0








            0







            I posted a Replace script here 2 days ago If text string contains certain words, wrap those words in a span tag.



            Findstr



            "^(SERVERNAME=x22^)^([a-z]+^)^(x22^)"


            Replace with



            $1WHATEVERYOUWANT$3


            $1 is first set brackets, $2 second, and $3 third. Above carets are escaping it for CMD - it looks like this after parsing (SERVERNAME=")([a-z]+)(")






            share|improve this answer















            I posted a Replace script here 2 days ago If text string contains certain words, wrap those words in a span tag.



            Findstr



            "^(SERVERNAME=x22^)^([a-z]+^)^(x22^)"


            Replace with



            $1WHATEVERYOUWANT$3


            $1 is first set brackets, $2 second, and $3 third. Above carets are escaping it for CMD - it looks like this after parsing (SERVERNAME=")([a-z]+)(")







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited May 23 '17 at 12:14









            Community

            11




            11










            answered Apr 9 '15 at 7:02









            SerenitySerenity

            1293




            1293













            • Serenity thank you for your post but i can't seem to get it working?

              – H. H. Shabastari
              Apr 9 '15 at 7:58











            • $1 contains Servername=", $2 contains the actual servername alpha only, if using underscore for real, change [a-z] to [a-z_]. I am only specifing lower case as I expect you would run it with ignore case option. Also as that code is lifted from a file of similar functions you need to remove the lines Sub ReplaceCmd and End Sub. Then cscript //nologo "C:path to scriptscript.vbs" "" i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" < "c:filetoprocess.txt" > Outputfile.txt.

              – Serenity
              Apr 9 '15 at 8:17











            • skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121 is where you can download filter0.8.zip as a file easy to use. Then Filter replace i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" "$1YourServerName$3" < csv.txt > output.txt. Filter has 19 text file functions and many options and is sample code for vbs processing of text files. Showing how easy it is.

              – Serenity
              Apr 9 '15 at 8:20













            • Serenity,I don't know what is going on. You want me to create a vbs script? I am not getting howto parse this and replace the value with a hardcoded value. Can you please paste the script to change the value after findstr? I am sorry to not understand this:(

              – H. H. Shabastari
              Apr 9 '15 at 8:23













            • You can't use findstr. It doesn't do replace. If you want a replace program you have to make your own.

              – Serenity
              Apr 9 '15 at 8:25





















            • Serenity thank you for your post but i can't seem to get it working?

              – H. H. Shabastari
              Apr 9 '15 at 7:58











            • $1 contains Servername=", $2 contains the actual servername alpha only, if using underscore for real, change [a-z] to [a-z_]. I am only specifing lower case as I expect you would run it with ignore case option. Also as that code is lifted from a file of similar functions you need to remove the lines Sub ReplaceCmd and End Sub. Then cscript //nologo "C:path to scriptscript.vbs" "" i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" < "c:filetoprocess.txt" > Outputfile.txt.

              – Serenity
              Apr 9 '15 at 8:17











            • skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121 is where you can download filter0.8.zip as a file easy to use. Then Filter replace i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" "$1YourServerName$3" < csv.txt > output.txt. Filter has 19 text file functions and many options and is sample code for vbs processing of text files. Showing how easy it is.

              – Serenity
              Apr 9 '15 at 8:20













            • Serenity,I don't know what is going on. You want me to create a vbs script? I am not getting howto parse this and replace the value with a hardcoded value. Can you please paste the script to change the value after findstr? I am sorry to not understand this:(

              – H. H. Shabastari
              Apr 9 '15 at 8:23













            • You can't use findstr. It doesn't do replace. If you want a replace program you have to make your own.

              – Serenity
              Apr 9 '15 at 8:25



















            Serenity thank you for your post but i can't seem to get it working?

            – H. H. Shabastari
            Apr 9 '15 at 7:58





            Serenity thank you for your post but i can't seem to get it working?

            – H. H. Shabastari
            Apr 9 '15 at 7:58













            $1 contains Servername=", $2 contains the actual servername alpha only, if using underscore for real, change [a-z] to [a-z_]. I am only specifing lower case as I expect you would run it with ignore case option. Also as that code is lifted from a file of similar functions you need to remove the lines Sub ReplaceCmd and End Sub. Then cscript //nologo "C:path to scriptscript.vbs" "" i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" < "c:filetoprocess.txt" > Outputfile.txt.

            – Serenity
            Apr 9 '15 at 8:17





            $1 contains Servername=", $2 contains the actual servername alpha only, if using underscore for real, change [a-z] to [a-z_]. I am only specifing lower case as I expect you would run it with ignore case option. Also as that code is lifted from a file of similar functions you need to remove the lines Sub ReplaceCmd and End Sub. Then cscript //nologo "C:path to scriptscript.vbs" "" i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" < "c:filetoprocess.txt" > Outputfile.txt.

            – Serenity
            Apr 9 '15 at 8:17













            skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121 is where you can download filter0.8.zip as a file easy to use. Then Filter replace i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" "$1YourServerName$3" < csv.txt > output.txt. Filter has 19 text file functions and many options and is sample code for vbs processing of text files. Showing how easy it is.

            – Serenity
            Apr 9 '15 at 8:20







            skydrive.live.com/redir?resid=E2F0CE17A268A4FA!121 is where you can download filter0.8.zip as a file easy to use. Then Filter replace i "^(SERVERNAME=x22^)^([a-z_]+^)^(x22^)" "$1YourServerName$3" < csv.txt > output.txt. Filter has 19 text file functions and many options and is sample code for vbs processing of text files. Showing how easy it is.

            – Serenity
            Apr 9 '15 at 8:20















            Serenity,I don't know what is going on. You want me to create a vbs script? I am not getting howto parse this and replace the value with a hardcoded value. Can you please paste the script to change the value after findstr? I am sorry to not understand this:(

            – H. H. Shabastari
            Apr 9 '15 at 8:23







            Serenity,I don't know what is going on. You want me to create a vbs script? I am not getting howto parse this and replace the value with a hardcoded value. Can you please paste the script to change the value after findstr? I am sorry to not understand this:(

            – H. H. Shabastari
            Apr 9 '15 at 8:23















            You can't use findstr. It doesn't do replace. If you want a replace program you have to make your own.

            – Serenity
            Apr 9 '15 at 8:25







            You can't use findstr. It doesn't do replace. If you want a replace program you have to make your own.

            – Serenity
            Apr 9 '15 at 8:25




















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f29531621%2fbatch-looping-through-directory-find-all-xml-and-replace-a-certain-unknown-val%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Florida Star v. B. J. F.

            Danny Elfman

            Lugert, Oklahoma