batch string replace in files

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
tjholleran
Posts: 3
Joined: 23 Sep 2008 00:58

batch string replace in files

Post by tjholleran »

Hi,

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

t

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: batch string replace in files

Post 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.
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

Quad Master
Posts: 32
Joined: 15 Sep 2008 07:28

Re: batch string replace in files

Post 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.
Blog : Quad Tek Using : XYplorer v7.60.0000, 09-Sep-2008
Quick Learning XY Newbie ;) [ My Wishlist | XYRoadMap | XYWiki ]

tjholleran
Posts: 3
Joined: 23 Sep 2008 00:58

Re: batch string replace in files

Post 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

admin
Site Admin
Posts: 65188
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: batch string replace in files

Post 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.

serendipity
Posts: 3360
Joined: 07 May 2007 18:14
Location: NJ/NY

Re: batch string replace in files

Post 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.

j_c_hallgren
XY Blog Master
Posts: 5826
Joined: 02 Jan 2006 19:34
Location: So. Chatham MA/Clearwater FL
Contact:

Re: batch string replace in files

Post 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
Still spending WAY TOO much time here! But it's such a pleasure helping XY be a treasure!
(XP on laptop with touchpad and thus NO mouse!) Using latest beta vers when possible.

tjholleran
Posts: 3
Joined: 23 Sep 2008 00:58

Re: batch string replace in files

Post by tjholleran »

Thank you all for the feedback.

T

Post Reply