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

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

Re: Where to start with recursive file operations


From: Kevin Rodgers
Subject: Re: Where to start with recursive file operations
Date: Mon, 01 Nov 2004 10:22:34 -0700
User-agent: Mozilla Thunderbird 0.8 (X11/20040916)

Andrei Stebkov wrote:
> I would like to write a function that finds files recursively starting from
> the current directory, opens files based on given extension and does some
> operations on them. For instance, checks out the file (from CVS or
> Perforce), selects the whole buffer, indents the contents and save it.
> Also I'd like to have same kind of function that would search and replace in
> multiple files.
> As all the problems that I listed here stem from the same root (recursive
> search) I need a few pointers about the basic built-in emacs functions of
> this domain. The function of this nature must be already written, I just
> couldn't find them.

I would write a small shell script that uses the find command to
generate the file names, and use emacs' command line options to do the
processing:

#!/bin/sh

find . -type f -name "*.ext" -print |
while IFS= read -r file; do
  emacs --batch "$file" \
        --eval "(vc-checkout buffer-file-name)" \
        --eval "(indent-region (point-min) (point-max) nil)" \
        --funcall save-buffer
done

--
Kevin Rodgers


reply via email to

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