I need to update a single parameter within a large set of .xml files. I read around and using a single line of perl at the windows command line I can get it to do substitutions a file at a time, but I am struggling to get perl to do all the files at once.
perl -pi.bak -e "s/(\d+\.\d+E-\d+)/2.2E-6/g;" test.xml
This works, however when I attempt to change it to something like
perl -pi.bak -e "s/(\d+\.\d+E-\d+)/2.2E-6/g;" *.xml
I get "Can't open *.xml: Invalid argument"
perl -pi.bak -e "s/(\d+\.\d+E-\d+)/2.2E-6/g;" .xml
Gives me "Can't open .xml: No such file or directory"
I tried to see if I could call it from within another perl script using system(), however that seems to take issue with the use of quotation marks, and may not the best way to do this.
Summary:
Problem - I have a large number of .xml files within which I want to change a single parameter. I have to be able to do this on a windows machine and ideally I would like to work towards a solution that would enable me to automate this in a script so I can loop through numerous parameter value substitutions (with a call to a separate program that takes the .xml files as an input in between substitutions).
Thanks for any help you can offer.
Try this:
for /r %i in (*.xml) do perl -pi.bak -e "s/(\d+.\d+E-\d+)/2.2E-6/g;" %i
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With