[?] Find String & Replace with Random String from List - Tool/Script?

Making or wanting help making your own asset? Check in here
Rhino
Retired PR Developer
Posts: 47909
Joined: 2005-12-13 20:00

[?] Find String & Replace with Random String from List - Tool/Script?

Post by Rhino »

Hey guys,

Its not often that I ask for help in here but I need to find some kind of Tool or Script that will allow me to search a text file for a word or string, ideally even multiple strings but that isn't critical, and then be able to replace those finds with one of the strings from the list, randomly.

So for an example, every time it finds "Find_Word_A" in the text file, it will replace it with one of the set words in the list randomly, and three example replacing words in the list could be "Replace_Word_1", "Replace_Word_2", "Replace_Word_3", etc.
So this text:

Code: Select all

....... Find_Word_A .......... Find_Word_A
.........Find_Word_A ........... Find_Word_A ...........
would become something like:

Code: Select all

....... Replace_Word_2 .......... Replace_Word_1
......... Replace_Word_1 ........... Replace_Word_3 ...........
Now I'm sure a tool or script like this must exist but I can't seem to find anything that dose what I want on google. I might be just searching for the wrong thing but I can't think of any other searches.

So if anyone knows of a tool or script that will do what I need can you point me in the right direction, and if not, is anyone around here able to make me a tool/script that would do this?

Cheers! :mrgreen:

- Thread copied to: https://www.realitymod.com/forum/f56-ma ... cript.html
Last edited by Rhino on 2017-05-20 01:51, edited 1 time in total.
Image
{ZW}C-LOKE
Posts: 202
Joined: 2012-11-26 20:13

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by {ZW}C-LOKE »

Try Text Mechanic? - Text Manipulation Tools and look under text obfuscation tools.

Or, you could try this:
Replace Genius - Automated Text & Data Processing Freeware

Or this:
fnr.exe - Find And Replace Tool - Home

Or this:
JetBrains .NET Tools Blog ? Introducing ReSharper 5.0: Structural Search and Replace


But generally, you're looking for something that can search and replace, with obfuscation abilities.
Image
Rhino
Retired PR Developer
Posts: 47909
Joined: 2005-12-13 20:00

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by Rhino »

{ZW}C-LOKE wrote:Try Text Mechanic? - Text Manipulation Tools and look under text obfuscation tools.

Or, you could try this:
Replace Genius - Automated Text & Data Processing Freeware

Or this:
fnr.exe - Find And Replace Tool - Home

Or this:
JetBrains .NET Tools Blog ? Introducing ReSharper 5.0: Structural Search and Replace


But generally, you're looking for something that can search and replace, with obfuscation abilities.
Can't see how any of them can do what I want looking at there features, other than possibly the last but that's because its features aren't fully explained and looks pretty complicated. Are you sure they can do what I want because I can't see it?

I'm also not looking to do "Obfuscation", which from what I can tell from its definition means:
Obfuscation (or beclouding) is the hiding of intended meaning in communication, making communication confusing, wilfully ambiguous, and harder to interpret.
I'm looking at replacing the code with a set list of replacements, not to screw up my code with random letters or numbers, or turn my code into binary code etc :p
Last edited by Rhino on 2013-11-01 06:38, edited 2 times in total.
Image
{ZW}C-LOKE
Posts: 202
Joined: 2012-11-26 20:13

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by {ZW}C-LOKE »

. yeah just ignore all that... found it... see below.
Last edited by {ZW}C-LOKE on 2013-11-01 06:46, edited 1 time in total.
Image
Rhino
Retired PR Developer
Posts: 47909
Joined: 2005-12-13 20:00

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by Rhino »

cool cheers, will give it a go :)
Image
{ZW}C-LOKE
Posts: 202
Joined: 2012-11-26 20:13

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by {ZW}C-LOKE »

Good stuff... Hope it works out for you, good luck!
Image
Rhino
Retired PR Developer
Posts: 47909
Joined: 2005-12-13 20:00

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by Rhino »

{ZW}C-LOKE wrote:Good stuff... Hope it works out for you, good luck!
It dose work cheers, but is pretty complicated and time consuming to even do one replace type and I need to do quite a few different replacements :(

Also looks like its only a free trial of the tool for 21 days, full one costs $40...

Guess the only perfect solution to me would be to get a tool or script need to do excatly what I need with also multiple find and replace lists in it. Anyone up for making me this tool/script? Its for PR work :D


EDIT: although if I don't do this too often it isn't so bad, cheers for the help, even with its being pretty complicated and time consuming it still going to save me and other devs lots of time and also give a much better result as a result :D
Last edited by Rhino on 2013-11-01 07:29, edited 2 times in total.
Image
Hjid
Posts: 75
Joined: 2009-04-28 18:35

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by Hjid »

This might be of interest.

https://dl.dropboxusercontent.com/u/266 ... eplace.zip

It's actually an "adjective story" generator I wrote a while ago, with some added documentation.
[img]http://www.realitymod.com/forum/uploads/signatures/sigpic33103_1.gif[/img]
LITOralis.nMd
Retired PR Developer
Posts: 5658
Joined: 2010-04-10 16:15

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by LITOralis.nMd »

How random does this need to be?

This is free ad will work for you:
Replace Genius - Automated Text & Data Processing Freeware
Use the find and replace function,
either create <tags> of a batch replacement list to store all the replacement words/phrases.
UTurista
PR:BF2 Developer
Posts: 985
Joined: 2011-06-14 14:13

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by UTurista »

And done,
https://www.dropbox.com/s/9vbzd0vgg6ko08e/UFinder.exe

Was tired of studding so I made that, Very simple UI you drag the file, you place the keyword followed by the replacing words and press "begin".

35Kp, portable and If I tested correctly doesn't need extra Dlls or something like that, only down side is it was made in ~1-2h so lacks on catching some(all) file exceptions. but its all good :D

edit: only tested with .tweak and .txt

edit:fixed broken URL
Last edited by UTurista on 2013-11-13 15:52, edited 2 times in total.
Image


Dont question the wikipedia! Just because it reports different things on different languages does not make it unreliable source!
{ZW}C-LOKE
Posts: 202
Joined: 2012-11-26 20:13

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by {ZW}C-LOKE »

'[R-COM wrote:LITOralis.nMd;1960837']How random does this need to be?

This is free ad will work for you:
Replace Genius - Automated Text & Data Processing Freeware
Use the find and replace function,
either create <tags> of a batch replacement list to store all the replacement words/phrases.
Very specifically he's looking for something that can search for a word or literal string, and replace it with a random word from a separate list or file... I think.
Image
Rhino
Retired PR Developer
Posts: 47909
Joined: 2005-12-13 20:00

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by Rhino »

O_turista_portugues wrote:And done,
https://www.dropbox.com/s/wkavdqw30jc0ghr/UFinder.exe

Was tired of studding so I made that, Very simple UI you drag the file, you place the keyword followed by the replacing words and press "begin".

35Kp, portable and If I tested correctly doesn't need extra Dlls or something like that, only down side is it was made in ~1-2h so lacks on catching some(all) file exceptions. but its all good :D

edit: only tested with .tweak and .txt
Sorry meant to reply to this sooner but was busy last weekend then forgot :(

Nice work, haven't had a chance to test this yet but it looks to be excatly what I'm looking for but would it also be possible to tweak this slightly to be able to search for multiple words as well on top of replacing them with multiple words randomly? :)

Cheers! :D
Image
UTurista
PR:BF2 Developer
Posts: 985
Joined: 2011-06-14 14:13

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by UTurista »

[R-DEV]Rhino wrote:Sorry meant to reply to this sooner but was busy last weekend then forgot :(

Nice work, haven't had a chance to test this yet but it looks to be excatly what I'm looking for but would it also be possible to tweak this slightly to be able to search for multiple words as well on top of replacing them with multiple words randomly? :)

Cheers! :D
Of course, but would they share the same pool?

Meaning:
TargetWord - A, B,C
Switch pool - 1,2,3
Would you want A,B and C to be replaced (randomly) by 1, 2,3 or you would like a pool per word?
Image


Dont question the wikipedia! Just because it reports different things on different languages does not make it unreliable source!
Rhino
Retired PR Developer
Posts: 47909
Joined: 2005-12-13 20:00

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by Rhino »

A, B, C to replace (randomly) by 1, 2, 3 is the most flexible but if its easy, a check box option to pool from the same would be awesome too so A, B, C was replaced randomly by A, B, C too as I would use both :D

Cheers!
Image
sweedensniiperr
Posts: 2784
Joined: 2009-09-18 10:27

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by sweedensniiperr »

What are you working on Rhino? 8-)
Image
UTurista
PR:BF2 Developer
Posts: 985
Joined: 2011-06-14 14:13

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by UTurista »

And here it is, took longer to test it than making it
https://www.dropbox.com/s/5iwsd91nfdeebph/UFinder.exe

You're now able to insert multiple words in the 'Replace' text box.
UFinder will search one of these words and replace it by one, at random, in the 'with' selection.

Eventually, I'll add a way to being able to ignore spaces, but for now users need to watch out for it.

Also any feedback is appreciated and feel free to suggest improvements I just found I love making these small programs.

edit: Hmm after testing the download I start to think I should invest in code Signing, but it's seems expensive :(
Last edited by UTurista on 2013-11-14 23:33, edited 1 time in total.
Image


Dont question the wikipedia! Just because it reports different things on different languages does not make it unreliable source!
Rhino
Retired PR Developer
Posts: 47909
Joined: 2005-12-13 20:00

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by Rhino »

Awesome cheers, will try and test it this weekend :D
Image
Rhino
Retired PR Developer
Posts: 47909
Joined: 2005-12-13 20:00

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by Rhino »

Right got a chance to test this and it works really well, cheers! :D

If your up for working on this a bit more then I've got a few suggestions to slightly speed up my work flow but tbh, that's only a convince thing for me and isn't urgent so unless you really want to work on this more, its perfectly fine as it is.

Also am I allowed to re-distribute this possibly in the future, giving you credit for it of-course?

Cheers! :D
Image
UTurista
PR:BF2 Developer
Posts: 985
Joined: 2011-06-14 14:13

Re: [?] Find String & Replace with Random String from List - Tool/Script?

Post by UTurista »

Glad you like it, give those suggestions and I'll try to implement them, like I said I like doing this.

About re-distribute feel free to do it.
Image


Dont question the wikipedia! Just because it reports different things on different languages does not make it unreliable source!
Post Reply

Return to “PR:BF2 Community Modding”