Page 1 of 2

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

Posted: 2013-11-01 05:45
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

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

Posted: 2013-11-01 05:57
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.

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

Posted: 2013-11-01 06:32
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

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

Posted: 2013-11-01 06:37
by {ZW}C-LOKE
. yeah just ignore all that... found it... see below.

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

Posted: 2013-11-01 06:42
by {ZW}C-LOKE

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

Posted: 2013-11-01 06:44
by Rhino
cool cheers, will give it a go :)

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

Posted: 2013-11-01 06:57
by {ZW}C-LOKE
Good stuff... Hope it works out for you, good luck!

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

Posted: 2013-11-01 07:04
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

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

Posted: 2013-11-01 11:30
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.

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

Posted: 2013-11-01 12:19
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.

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

Posted: 2013-11-01 15:27
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

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

Posted: 2013-11-01 19:56
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.

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

Posted: 2013-11-10 16:19
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

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

Posted: 2013-11-13 15:55
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?

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

Posted: 2013-11-13 16:24
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!

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

Posted: 2013-11-14 21:29
by sweedensniiperr
What are you working on Rhino? 8-)

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

Posted: 2013-11-14 23:20
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 :(

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

Posted: 2013-11-15 16:17
by Rhino
Awesome cheers, will try and test it this weekend :D

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

Posted: 2013-11-17 15:52
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

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

Posted: 2013-11-18 12:23
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.