[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svn rename glob?

From: David Weintraub <qazwart_at_gmail.com>
Date: Mon, 12 Jan 2009 14:24:01 -0500

If this is BASH, you should be able to do something like this:

for file in *.foo
do
    svn mv $file ${file%%.foo).bar
done

The "%%" removes the right hand side of $file that matches the glob
pattern (.foo). Do a "man bash" and search for "Parameter Expansion".
You'll see an entry for "${parameter##word}" and "
${parameter%%word}".

And, if you're using an "older shell" that doesn't take this form of
parameter expansion (like plain ol' Bourne shell).

for file in *.foo
do
    svn mv $file `basename $file .foo`.bar
done

Don't forget that basename not only removes the directory name, but
also a suffix if given. Since we are not matching in subdirectories,
we don't have to worry about basename removing the directory name.
Else, we may need this:

find . -name "*.foo" | while read file
do
   svn mv $file `dirname $file`/`basename $file .foo`.bar
done

That's what you get with two decades in working with Unix. Let me know
if you also need any help on setting up a UUCP network or cpio. I'm
just chalked full of obsolete information!

I was working on the Internet back when it really was a series of tubes!

On Sat, Jan 10, 2009 at 10:23 PM, Blair Zajac <blair_at_orcaware.com> wrote:
> Steve Cohen wrote:
>> I wish to rename all files in a directory tree by changing their
>> extension (keeping rest of filename the same) without losing history.
>>
>> Before I screw myself up can someone tell me if there is a way to do
>> this with a single command line? If not, what would be the easiest way
>> to perform this operation?
>
> No, you'll have to do this yourself.
>
> Something like this bash script:
>
> for f in *.foo; do
> g="`echo $f | sed -e s'/.foo$/.bar/'`"
> echo Renaming $f to $g
> svn rename "$f" "$g"
> done
>
> Regards,
> Blair
>
> --
> Blair Zajac, Ph.D.
> CTO, OrcaWare Technologies
> <blair_at_orcaware.com>
> Subversion training, consulting and support
> http://www.orcaware.com/svn/
>
> ------------------------------------------------------
> http://subversion.tigris.org/ds/viewMessage.do?dsForumId=1065&dsMessageId=1016398
>
> To unsubscribe from this discussion, e-mail: [users-unsubscribe_at_subversion.tigris.org].
>

-- 
--
David Weintraub
qazwart_at_gmail.com
Received on 2009-01-12 20:25:01 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.