27 Jun 15:50
Re: Rename multiple files at once
From: terry tyson <beebum <at> gmail.com>
Subject: Re: Rename multiple files at once
Newsgroups: gmane.os.openbsd.misc
Date: 2007-06-27 13:50:45 GMT
Subject: Re: Rename multiple files at once
Newsgroups: gmane.os.openbsd.misc
Date: 2007-06-27 13:50:45 GMT
On 6/27/07, Will Maier <willmaier <at> ml1.net> wrote:
>
> On Wed, Jun 27, 2007 at 02:37:07PM +0200, Pieter Verberne wrote:
> > How do I rename multiple files at once?
>
> This is a function of your shell, not mv. See ksh(1), zsh(1), etc...
>
> Alternatively, you could write a simple script/function to address
> the same problem:
>
> for FILE in *jpg; do
> NEW=$(echo $FILE | sed -e 's/\.jpg$/_thumb.jpg/')
> mv "${FILE}" "${NEW}"
> done
Will, I like your use of sed on this. I did a similar thing with awk.
for i in *.jpg do
outfile=`echo $i | awk -F. '{print $1"_thumb.jpg"}'`
mv $i $outfile
done
Terry
RSS Feed