Easier mass find and replace?

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
hisaku
Posts: 2
Joined: Wed Sep 06, 2006 8:12 pm

Easier mass find and replace?

Post by hisaku »

I searched the forums under "find and replace" but after going through the first 5 pages I couldn't find anything that addressed my issue. So I apologize if its been covered elsewhere in the forums.

I wanted to do a simple mass find and replace on multiple files, replace "abc" with "xyz". Is there an easier way than doing:

1)Find In Files
2)Open all those files
3)Find and Replace in all documents.

I"m asking this because the directory to search under is large and it will freeze up when doing step 1. So I have to search the individual subdirectories, etc. It will also freeze up if I try to open up too many files. I'm running 512mb of memory.

I guess I'm looking for a "search and replace". Where it would open up the file, do the find and replace, then close, then repeat. Even if it will take a long time, it's something I can run when not at my desk.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Post by ben_josephs »

Have a look at Helios's own WildEdit (http://www.textpad.com/products/wildedit/), which is designed "to make the same changes to a set of text files in a folder hierarchy".
hisaku
Posts: 2
Joined: Wed Sep 06, 2006 8:12 pm

Post by hisaku »

Thanks! That was exactly what I was looking for. When I used it, although it did take a long time, I let it run and when it was done returned all the results and a nice report at the end.

Two things for people who had the same dilema as me:

1)It may take awhile to bring up network computers and shared drives, but I just let it be and it came up eventually.

2)When starting the replace with the green arrow, the red cancel square appears. Even though you don't get any indication that its searching or going through files, rest assure it is searching. The program may appear like its not responding, but will refresh itself every so often. You will not get any status or reporting till the search has been complete.
BillSeurer
Posts: 3
Joined: Wed Mar 03, 2004 10:00 pm

Re: Easier mass find and replace?

Post by BillSeurer »

hisaku wrote:I guess I'm looking for a "search and replace". Where it would open up the file, do the find and replace, then close, then repeat. Even if it will take a long time, it's something I can run when not at my desk.
If you have Perl installed you can do it easily with one command on the command line. For example,

perl -i.bak -p -e 's/some string/some other string/g;' *.txt */*.txt

(that's one line)

That command will go through all the files whose names end with ".txt" in the current folder and all the ones under it and replace the string "some string" witht he string "some other string". the "-i.bak" will cause it to make a backup copy of all the files with ".bak" added to the file names.
ben_josephs
Posts: 2461
Joined: Sun Mar 02, 2003 9:22 pm

Re: Easier mass find and replace?

Post by ben_josephs »

BillSeurer wrote:perl -i.bak -p -e 's/some string/some other string/g;' *.txt */*.txt
Not on a DOSish (e.g., COMMAND, CMD, 4NT) command line it won't. On a unixish command line it might, but the DOSish one won't expand the wildcards (especially the ones in directory components) and it handles quotes differently.
Post Reply