help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to apply a list of regex replaces to multiple files?


From: David Combs
Subject: Re: How to apply a list of regex replaces to multiple files?
Date: Fri, 1 Aug 2008 08:38:05 +0000 (UTC)

In article <8763ron1dr.fsf@lion.rapttech.com.au>,
Tim X  <timx@nospam.dev.null> wrote:
>"michael.l" <michael.lommel@gmail.com> writes:
>
>> On Jul 1, 1:38 am, "Lennart Borgman (gmail)"
>> <lennart.borg...@gmail.com> wrote:
>>> michael.l wrote:
>>> > I've browsed the messages here and have googled but don't see a clear
>>> > solution yet. I have about 900 documents to which I need to apply a
>>> > list of maybe 40 separate regex search and replaces. I would like to
>>> > feed a list of the regex expressions and replacements to emacs and
>>> > have it applied to a directory of the files. Any solutions? Keyboard
>>> > macros don't seem like the right solution....
>>>
>>> Sounds like the best would be writing a small elisp function to do the job.
>>
>> I'll look into elisp...Struggled with perl to do this....
>
>Well, not meaning to sound rude, but if you had trouble doing this with
>perl, I suspect you will have even a harder time with elisp. I only say
>this as, from your description, perl would be my first choice and it
>should be pretty straight forward. I personally find perl regexp a lot
>easier to work with and a lot more powerful than elisp's
>implementation. After perl, my second choice would
>likely be sed (actually, sed may be my first choice if you have quite a
>number of regexp because you could put them all in a file and then just
>run sed on the files - essentially, no programming. However, sed can be
>a little tricky to wrap your head around as it has a hell of a lot of
>power.
>
>
>Tim
>
>-- 
>tcross (at) rapttech dot com dot au


What I used to do is use "ex" (part of vi) or maybe
it was "ed".

Anyway, it had a "source" stmt, ie "source myRegexAndSubstituteCmds.ex",
plus a sh-script

ex foo.bar
source <something>

ex foo2.bar
source <same thing>

etc



something like that.  Anyway, it worked, for changing variable-names in
about 100 program files, totally hands-off.

Back then perl likely didn't even exist.


David






reply via email to

[Prev in Thread] Current Thread [Next in Thread]