|
|
Know Of Any Block Text Search & Replace Tools ( Across Multiple Files ) | ||
Discussion by miCRoSCoPiC^eaRthLinG with 11 Replies.
Last Update: March 27, 2007, 4:17 pm | |||
It'll be really great if someone can suggest such a tool.
Regards,
m^e
Mon Mar 26, 2007 Reply New Discussion
- 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.
Mon Mar 26, 2007 Reply New Discussion
Progress so far:-
> Add/Edit/Remove files to the list
> Search Forward + Backward in multiple files
> Replace / Replace All
> Backup Files before Replace
Mon Mar 26, 2007 Reply New Discussion
Mon Mar 26, 2007 Reply New Discussion
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.
Mon Mar 26, 2007 Reply New Discussion
Problems
- It finds and replaces ONLY the FIRST INSTANCE of a string in a file. The S & R function halts after that.
- 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

- Back-up doesn't work yet
- 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:
- Include an option to add folders instead of single files.
- Include an option to recurse into subfolders and perform the S & R
- 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.
Mon Mar 26, 2007 Reply New Discussion
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.
Mon Mar 26, 2007 Reply New Discussion
Mon Mar 26, 2007 Reply New Discussion
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
You might give it a try, I'll look around and see if I still have the installer for it if you need.
vujsa
Mon Mar 26, 2007 Reply New Discussion
QUOTE (miCRoSCoPiC)
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...Link: view Post: 100504
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
Mon Mar 26, 2007 Reply New Discussion
QUOTE
It finds and replaces ONLY the FIRST INSTANCE of a string in a file. The S & R function halts after that.
QUOTE
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
In the testings that I have been doing, it pops up with Replaced (0) Instances after a complete REPLACE ALL. I presume the replace text you are using creates another instance of the find text.
For Example:-
Find Text: Adam
Replace Text: Madam
Source Text: Adam ate the apple.
Final Text: Madam ate the apple.
It would be easier for me if you could attach the files you were testing on.
QUOTE
Back-up doesn't work yet
QUOTE
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.
I'll include the filters to stop it from doing that.
Mon Mar 26, 2007 Reply New Discussion
Incorporated most of the features and hopefully bugs would be minimal.
You can get it from http://www.ntek.astahost.com/wip/searchandreplace/
Tue Mar 27, 2007 Reply New Discussion
Avg Free Vs Avast! Free (38)
|
(3) Portableapps: Your On-road Productivity Companion
|
Index




