|
Boom
just a tester

Registered: 06/16/04
Posts: 11,252
Loc: Cypress Creek
|
Help me, batch file gurus!
#6713806 - 03/26/07 06:21 PM (17 years, 1 month ago) |
|
|
I know this is 100 times easier in Linux..but I want to make a script for windows that simply searches and replaces xml tags
like I changed my mind about calling some element <apple> and now want all of the <apple> (and </apple>) tags to says <banana>
I realize this would be a lot easier and whatnot if I downloaded the SED port for windows, but this needs to run on unmodified windows machines. I don't know shit about batch files, really
If anyone off the top of their head knows a simple way to do this, lemma know! thanks
|
klassasin
La vida es buena! Disfrutala!



Registered: 10/05/06
Posts: 55
Loc: Midwest. USA
Last seen: 1 year, 13 days
|
Re: Help me, batch file gurus! [Re: Boom]
#6713816 - 03/26/07 06:25 PM (17 years, 1 month ago) |
|
|
This may help
Otherwise, I don't know of any simple methods to use. Ports (SED, Grep) would be easier, but you have already said that is impossible. Batch files aren't really that useful. I <3 Linux (Slackware!) for that reason.
|
Diploid
Cuban



Registered: 01/09/03
Posts: 19,274
Loc: Rabbit Hole
|
Re: Help me, batch file gurus! [Re: Boom]
#6713938 - 03/26/07 07:11 PM (17 years, 1 month ago) |
|
|
Get awk.
-------------------- Republican Values: 1) You can't get married to your spouse who is the same sex as you. 2) You can't have an abortion no matter how much you don't want a child. 3) You can't have a certain plant in your possession or you'll get locked up with a rapist and a murderer. 4) We need a smaller, less-intrusive government.
|
delta9
Active Ingredient


Registered: 10/28/04
Posts: 5,390
Loc: California
Last seen: 13 years, 6 months
|
Re: Help me, batch file gurus! [Re: Boom]
#6715668 - 03/27/07 04:35 AM (17 years, 1 month ago) |
|
|
Quote:
Booooom said: I know this is 100 times easier in Linux..but I want to make a script for windows that simply searches and replaces xml tags
like I changed my mind about calling some element <apple> and now want all of the <apple> (and </apple>) tags to says <banana>
I realize this would be a lot easier and whatnot if I downloaded the SED port for windows, but this needs to run on unmodified windows machines. I don't know shit about batch files, really
If anyone off the top of their head knows a simple way to do this, lemma know! thanks
You could write a semi-complicated script in JScript or VBScript (shudder!), BUT it would work on most every stock windows post 98 if done properly. String search and replace are common programming functions and good excersizes if you are interested in learning, but I think you just want to get things done, in which case you should download a program that automatically does batch search and replace (and there are MANY). If you want to mess around with it, I recommend JScript over VBScript unless you already know VB, VBA, or VBScript and are unfamiliar with JScript, Java, or C/C++/C#/PHP ; though if you REALLY want to learn to program I recommend writing it in C or C++ as you will have the most direct access to the windows API and it will work on practically every version of windows on the same architecture and be much faster than the script version.
-------------------- delta9
|
Seuss
Error: divide byzero



Registered: 04/27/01
Posts: 23,480
Loc: Caribbean
Last seen: 3 months, 8 days
|
Re: Help me, batch file gurus! [Re: Boom]
#6715741 - 03/27/07 06:34 AM (17 years, 1 month ago) |
|
|
load the file up in vi and type...
:%s#</apple>#</banana>#g :%s#<apple>#<banana>#g :wq
You can of course script this through ed instead, if you need to batch it... or use sed for that matter... Unix is your friend... 
Since you are on windows, you will need to install something like cygwin first.
|
|