Find and replace block of text (with other blocks of text) in multiple files

1

Is there a FREE utility out there for replacing blocks of text?

Something like notepad++'s find in files works for simple lines but in my case it's unusable since I need to target the entire block to avoid replacing the wrong thing and I also need to replace it with another block.

I've searched for similar questions but all seem to deal with line replacing not block replacing. :)

srcspider

Posted 2012-02-27T13:07:23.743

Reputation: 179

Question was closed 2012-11-18T14:53:16.223

Can you give us a little more info? What type of files; text, Word, HTML? How many files are you talking about? – CharlieRB – 2012-02-27T13:35:39.283

@CharlieRB typical source file, complex copyright notice and other metadata, number of files I'd say hundreds – srcspider – 2012-02-27T13:38:16.347

1

There is an answer to this here. Please read the comments to get the explanation for notepad++ ability to do this. This is the same for replacing text.

– CharlieRB – 2012-02-27T13:42:23.223

@CharlieRB that won't work, I need block replace and while notepad++ can get some sort of block replace though regular expression converting the actual block to a regular expression is a pain in the ass and on top of that notepad++ doesn't have support for the actual replacement text being a block; I've tryied several ways of doing it with it, doesn't work. Both the replaced and the new text are BLOCKS. – srcspider – 2012-02-27T13:51:31.757

Can you define what a "Block" of text is to you? To me, a block of text is just a group of sequential lines (and line-breaks). You may just have to sit down and write that "pain in the ass" RegEx. :) – Ƭᴇcʜιᴇ007 – 2012-02-27T13:54:23.457

@techie007 What do I do for the replacement where I can't insert line breaks? – srcspider – 2012-02-27T13:55:23.767

possible duplicate of Text editor on Windows to delete large block of copyright text in multiple source files?

– Ƭᴇcʜιᴇ007 – 2012-02-27T13:56:20.507

Insert them? "^M" "\r\n" etc., depending on what the editor supports. If your question is "How do I insert Line Breaks in Notepad++'s Replace?", that's a different question. :) – Ƭᴇcʜιᴇ007 – 2012-02-27T13:57:42.457

You do realize this is free help, right? Those who choose to help answer your question offer suggestions asking nothing in return. There is no guarantee the answers you get will be proper solution right from the start. You say you've tried several ways. How do I know what you've tried. [Edit] your question with what you've tried and those who read it will not have to ask you. – CharlieRB – 2012-02-27T14:00:06.213

@techie007 I'm not deleting, I'm replacing so it's not a duplicate. I've re-tested with extended and \n and this time it seems to work... dunno what happened last time it didn't replace properly. Thx. – srcspider – 2012-02-27T14:09:12.267

@CharlieRB until retesting it as far as I was aware that was one of the wrong answer (ie. didn't work) so I saw no point in mentioning such things (and still don't). Dunno why you're so angry about it. In any case, resolved. – srcspider – 2012-02-27T14:12:05.163

Answers

1

A google search for "replace in files" lead me to a couple good looking solutions

http://www.emurasoft.com/replall/ http://www.ultraedit.com/support/tutorials_power_tips/ultraedit/find_replace.html

I also recall windows grep doing this - http://www.wingrep.com/ though I don't have it installed at the moment.

Jody

Posted 2012-02-27T13:07:23.743

Reputation: 372

replall is "per line" not "per block" wingrep is "per line" as well; pretty sure ultraedit was too – srcspider – 2012-02-27T13:22:09.970

I know wingrep will do multiline, and I'm pretty sure ultraedit will too. You should be able to copy paste into the box. Worst case scenario you can use \n's to represent newlines. – Jody – 2012-02-27T14:38:21.173

managed to get it working from the discussion in the comments on the question. But thanks anyway! :) – srcspider – 2012-02-27T18:15:29.293

0

Try EditPad Lite. It has multiple line functionality.

Sheesh

Posted 2012-02-27T13:07:23.743

Reputation: 19

-1 he said MULTIPLE FILES. (not just multiple lines) Powergrep(also by JGsoft) would do it. I'm pretty sure that Editpad won't. Editpad is for individual files.. and is fantastic for it. Powergrep would do multiple. I doubt powergrep has a free version though. – barlop – 2014-02-22T20:17:21.757