is there a program with scriptable or macro find/replace

Chat about anything not covered in these forums, but keep it civil!

Post » Mon May 24, 2010 5:38 pm

in my current project, I'm going to need to do the same sequence of find/replace on text over and over throughout the development project. Is there a program that allows you to automate this? it would be extremely useful right about now.
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Mon May 24, 2010 8:12 pm

You could make a batch file and use commandline tools to do it. There are many different commandline tools you can use.

This commandline utility looks pretty good:[url:1tc3vuwi]http://www.programmersheaven.com/download/41236/download.aspx[/url:1tc3vuwi]

Example batch file:
[code:1tc3vuwi]@echo off
rem seach and replace batch
set myfile=main.cpp
ssr 0 "birds" "cows" "%myfile%"
ssr 0 "foo" "bar" "%myfile%"
set myfile=
[/code:1tc3vuwi]
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Tue May 25, 2010 12:27 am

not sure what you mean by macro and i might not be helping with what your asking but i know that word has a find and replace/replace all ect. thats pretty handy. again this might not be what you mean by macro :S
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Tue May 25, 2010 1:41 pm

thanks quazi and rojo.
I noticed after this post that notepad++ has a record macro feature, so I'll probably test that out first. [edit: nm, the macro recorder in notepad++ won't record find/replace actions, presumably because it only records what happens while the main program window is in focus[not the find/replace child window])

but what I meant quazi, is I have to find and replace several things in a row, in a certain order, like
Find "applesauce", replace with "butter"
Find "apple", replace with "pear"
Find "you", replace with "me"
Find "bloodcell", replace with "nanobot"

it's a long sequence of these, that I'll probably have to do a few hundred times before I'm done developing my current project. So it'd save me alot of time and carpal tunnel, if it was automated, and I just hit one key, and it did the whole process for me.
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Tue May 25, 2010 2:56 pm

So like why not make an app in Construct?
You could easily make something to load a text file, or copy pasta from the clipboard.

[url:221qxbve]http://sourceforge.net/apps/mediawiki/construct/index.php?title=System_Expressions#Text[/url:221qxbve]

In particular:
[code:221qxbve]Remove(source, string)
Removes all occurences of string within source [/code:221qxbve]
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed May 26, 2010 1:14 am

Depending upon what format your source text is in, Python can also make short work of such a problem. If you can import the text into a python string (or list of strings), or even paste it into a Construct EditBox object, you can do something like this:

[code:2l3t03l5]text = "one plus one equals two, and four minus three equals one."
terms = [['three', 'five'],
['four', 'seven'],
['two', 'four'],
['one', 'two']]
for find, repl in terms:
text = text.replace(find, repl)
print text[/code:2l3t03l5]

...which results in this:

[code:2l3t03l5]two plus two equals four, and seven minus five equals two.[/code:2l3t03l5]

There are some pretty powerful string methods built-in to Python. You can even do this in Construct. :)
B
3
S
2
G
2
Posts: 187
Reputation: 1,449

Post » Wed Jun 02, 2010 10:02 pm

[quote="lucid":3rbkqhhj]in my current project, I'm going to need to do the same sequence of find/replace on text over and over throughout the development project. Is there a program that allows you to automate this? it would be extremely useful right about now.[/quote:3rbkqhhj]
lucid, I think, that JGsoft PowerGREP is what you are looking for. You may also try this - Funduc Search and Replace. Sorry, both are shareware. I believe, that there is a freeware program somewhere, but I don't know exactly.

Suppose, it will help you.
B
2
S
1
G
3
Posts: 102
Reputation: 1,304


Return to Open Topic

Who is online

Users browsing this forum: Tostito2100 and 4 guests