Page 1 of 1

batch string replace in files

Posted: 23 Sep 2008 01:03
by tjholleran
Hi,

So ... is there a way to use the XYplorer awsomeness to batch tru files containing match strings ... replacing the strings?

t

Re: batch string replace in files

Posted: 23 Sep 2008 01:22
by j_c_hallgren
Hi and welcome to the XY forums!

I'm not sure if I fully understood what you wanted to do...could you better describe it so that we can give the appropriate answer? Because there are a wide variety of combinations that your initial statement could apply to, and which have differnt solutions.

Re: batch string replace in files

Posted: 23 Sep 2008 05:26
by Quad Master
tjholleran wrote:Hi,

So ... is there a way to use the XYplorer awsomeness to batch tru files containing match strings ... replacing the strings?

t

I am assuming that you want to replace a particular word in a list of files with some other word.

eg.

test1
test2
test3
test4

and you want to replace "test" with "hello" like this

hello1
hello2
hello3
hello4

This is my script.

Code: Select all

"What To Replace - With This"
 input $what,"What To Replace In The Selected Enteries", What;
 input $with,"Replace With This", With This;
 rename s, "$what/$with",p;
Hope this helps :)

Also check out the XYWiki its loaded with information on scripting.

Re: batch string replace in files

Posted: 24 Sep 2008 19:26
by tjholleran
Sorry, I was not clear enough.

I can see that renaming the files is str8 forward.

I want to search for all files containing a string in the contents of the file ... not the file name ... and then replace that string in all the files and just resave the files.

Hope that makes more sense,

Thanks,

T

Re: batch string replace in files

Posted: 24 Sep 2008 20:01
by admin
tjholleran wrote:Sorry, I was not clear enough.

I can see that renaming the files is str8 forward.

I want to search for all files containing a string in the contents of the file ... not the file name ... and then replace that string in all the files and just resave the files.

Hope that makes more sense,

Thanks,

T
Nope, not yet possible. But quite soon it will be easy using scripting. Just wait for commands ReadFile, WriteFile and Looping statements.

Re: batch string replace in files

Posted: 24 Sep 2008 20:24
by serendipity
admin wrote:
tjholleran wrote:Sorry, I was not clear enough.

I can see that renaming the files is str8 forward.

I want to search for all files containing a string in the contents of the file ... not the file name ... and then replace that string in all the files and just resave the files.

Hope that makes more sense,

Thanks,

T
Nope, not yet possible. But quite soon it will be easy using scripting. Just wait for commands ReadFile, WriteFile and Looping statements.
But if its a ini file then you can do this already using scripting. If not then like Don (admin) said wait for new commands.

Re: batch string replace in files

Posted: 24 Sep 2008 20:28
by j_c_hallgren
tjholleran wrote:I can see that renaming the files is str8 forward.

I want to search for all files containing a string in the contents of the file ... not the file name ... and then replace that string in all the files and just resave the files.
FYI: We're not limited to 140 chars here so we can spell out words in many cases, like "straight", ok?

And for your situation...I might recommend, for now, a freeware pgm whose author site seems to have vanished but I've used it for a couple of years...it was able to replace some things that other pgms couldn't...not sure if it's applicable to your case, but take a look, ok?

http://www.snapfiles.com/get/bkreplace.html

Re: batch string replace in files

Posted: 27 Sep 2008 19:37
by tjholleran
Thank you all for the feedback.

T