[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: feature request - save string from match pattern to var
From: |
James Youngman |
Subject: |
Re: feature request - save string from match pattern to var |
Date: |
Sat, 25 Sep 2010 21:05:52 +0100 |
On Fri, Sep 24, 2010 at 9:19 PM, Johannes Welser <address@hidden> wrote:
> Hi there,
>
> I can think of a nice feature for find in combination with the exec
> parameter: Save the matched string from the name parameter and save it
> into a special variable, say: <>
> With this you could easily do many additional tasks - like a batch
> renamer for example:
Many systems already have a binary called "rename" that already does
this. I can't remember if it deals correctly with file names that
contain newlines or which aren't text.
> find ./pictures/ -name "*.jpeg" -exec mv {} <>jpg \;
>
>
> How do you like this idea? Is this already implemented?
It's not implemented in GNU find, no. There are a number of problems
that would need to be overcome. For example what should happen in
the case where more than one -name predicate is given, or a -name
predicate contains any of the various other globbing wildcards.
Lastly, I'm not at all convinced that the semantics required for -exec
allow for pattern replacement of anything other than {}.
> Would you merge it into the package if I would implement it?
Not in this form, to be honest. Firstly because of the difficulties
I mentioned above. Secondly because a new feature for find needs to
justify the burden of maintaining and regression testing the
additional code (and documentation) for each release by being useful
to users of the program. While this feature _is_ useful, I don't
think it's so much more useful than alternative ways of doing the same
thing that the benefit justifies the additional burden.
James.