Welcome Guest ( Log In | Register )



2 Pages V   1 2 >  
Reply to this topicStart new topic
> Know Of Any Block Text Search & Replace Tools ( Across Multiple Files )
miCRoSCoPiC^eaRt...
post Mar 26 2007, 05:36 AM
Post #1


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411



The title says it all - am hunting for a freeware tool that'd allow me to search a BLOCK of text (as opposed to a line of text in most editors) across multiple files and replace it in all those files. Has anyone come across such a tool. I Googled and found a few paid ones and even gave a try to their trial versions - but all of them seemed buggy and ill-designed.

It'll be really great if someone can suggest such a tool.

Regards,
m^e
Go to the top of the page
 
+Quote Post
pyost
post Mar 26 2007, 09:47 AM
Post #2


Nenad Bozidarevic
Group Icon

Group: [MODERATOR]
Posts: 1,002
Joined: 7-November 05
From: Belgrade, Serbia
Member No.: 9,500



I haven't heard of such a program, but you could make it yourself. That way you would get exactly what you want and how you want it. I've even got an idea how to do it:
  • Three text boxes: files, search and replace
  • In each line of the first one would be a file you want to edit, the second one would contain what to search for, and the third what to replace it with
  • When clicked on "Start", the program would load each line of the second and the third box in a array.
  • After that, the program would load the file contents in an array (again, one element for each line)
  • The program would then search the file array to see if any sequence of members matches the one in the search array - if it does, it would be replaced with the sequence in the replace array
  • Finally, the file would be opened for writing and cleared, and then you'd write the new file array into it
  • Repeat the process for all files

Might not be so fast, but will definitely do what you need.
Go to the top of the page
 
+Quote Post
turbopowerdmaxst...
post Mar 26 2007, 10:25 AM
Post #3


Premium Member
Group Icon

Group: [HOSTED]
Posts: 372
Joined: 16-February 06
From: Kolkata, India
Member No.: 11,322



I was on the job myself. It would be called Mr. Block Text biggrin.gif.

Progress so far:-

> Add/Edit/Remove files to the list
> Search Forward + Backward in multiple files
> Replace / Replace All
> Backup Files before Replace



This post has been edited by turbopowerdmaxsteel: Mar 26 2007, 11:50 AM
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Mar 26 2007, 11:53 AM
Post #4


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411



Pyost, biggrin.gif I had the same thoughts too.. but who wants to go into the pain of writing one right now... lets see how turbo's software comes out..
Go to the top of the page
 
+Quote Post
turbopowerdmaxst...
post Mar 26 2007, 12:04 PM
Post #5


Premium Member
Group Icon

Group: [HOSTED]
Posts: 372
Joined: 16-February 06
From: Kolkata, India
Member No.: 11,322



Ok here goes the Work in Progress version.

http://ntek.astahost.com/wip/mrblocktext/

Hopefully, this would serve your purpose. Do mention the features you would like to be added/ripped off and any bugs that you encounter (I had to rush things 'cause of the classes). For now, the backups will be stored in the backup directory of the application with a timestamp prefix added to the filename.
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Mar 26 2007, 12:24 PM
Post #6


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411



Check it out and here are the problems:

Problems
  1. It finds and replaces ONLY the FIRST INSTANCE of a string in a file. The S & R function halts after that.
  2. After replacing a string, it pops-up a message-box saying "Replaced (x) Instances". That is fine - but it keeps reporting that it replaced an instance EVEN AFTER the replacing is over. What I mean is that supposing you've searched & replaced a particular string and there are no more instances of the same string in the file. If you the try S & R again, it still reports that 1 instance has been replaced ohmy.gif
  3. Back-up doesn't work yet
  4. The S & R function works on executables (.exes) too and dutifully screws them up even if there's NO POSSIBILITY of such a string occurring inside a .exe.

Suggestions:
  1. Include an option to add folders instead of single files.
  2. Include an option to recurse into subfolders and perform the S & R
  3. Add a file filter along with the above two - so you can specify say, *.txt or *.htm and it'll look for the string in only those file types.
Go to the top of the page
 
+Quote Post
ethergeek
post Mar 26 2007, 03:09 PM
Post #7


Premium Member
Group Icon

Group: [HOSTED]
Posts: 393
Joined: 9-March 07
From: Tucson, AZ
Member No.: 20,794



If you don't need a gui program, awk will do this for you. The syntax can be a little confusing, but if you read the manpage you should have no problem devising an awk statement that will do anything you like.

Also, a perl script could do this extremely easily in less than 20 lines of code.

I forgot to mention, awk is both freeware AND open source.

This post has been edited by ethergeek: Mar 26 2007, 03:09 PM
Go to the top of the page
 
+Quote Post
miCRoSCoPiC^eaRt...
post Mar 26 2007, 04:06 PM
Post #8


PsYcheDeLiC dR3aMeR
Group Icon

Group: Admin
Posts: 2,242
Joined: 29-January 05
From: Nakorn Chaisri, Thailand
Member No.: 2,411



ethergeek: If it was for myself - I'd probably use awk. Would have been a much faster and smoother approach. But this is for someone else, who sadly has no clue how to work out of the Windows box. So there... wacko.gif
Go to the top of the page
 
+Quote Post
vujsa
post Mar 26 2007, 04:40 PM
Post #9


Absolute Newbie
Group Icon

Group: Admin
Posts: 887
Joined: 20-February 05
From: Indianapolis, Indiana, USA (Midwest)
Member No.: 2,714



Well, I use CuteHTML for most of my editing needs and it includes a text replacement feature that I use a lot. It will search and replace text on the active document or all open documents.

It isn't very fancy and doen't use any regular expressions but with a little practice, you'll figure out how to overcome that.

It will do large blocks of text as well. The demo version stops providing code tips and more advanced features but the find and replace feature works great.

I use an older version - CuteHTML LE from 2001 tongue.gif

You might give it a try, I'll look around and see if I still have the installer for it if you need.

vujsa
Go to the top of the page
 
+Quote Post
ethergeek
post Mar 26 2007, 05:02 PM
Post #10


Premium Member
Group Icon

Group: [HOSTED]
Posts: 393
Joined: 9-March 07
From: Tucson, AZ
Member No.: 20,794



QUOTE(miCRoSCoPiC^eaRthLinG @ Mar 26 2007, 09:06 AM) *
ethergeek: If it was for myself - I'd probably use awk. Would have been a much faster and smoother approach. But this is for someone else, who sadly has no clue how to work out of the Windows box. So there... wacko.gif


Roger that...though you still might be able to incorporate awk as the replacement backend for the text search/replace instead of writing your own regexes and routines. You can abstract the operation but still maintain the power of awk smile.gif
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic

Collapse

> Similar Topics

Topics Topics
  1. Context Programmer's Editor(2)
  2. Pdf Creator: Create Pdf Files For Free(5)
  3. Php Designer 2005(1)
  4. Pov Tools(0)
  5. Restoration(8)
  6. Ip Tools 2.50(1)
  7. Indexmaker 1.01(5)
  8. Free Plugins For Dreamweaver(3)


 



- Lo-Fi Version Time is now: 5th September 2008 - 12:22 PM