On Sat, 11 Jan 2003 17:22:43 -0800
Matt Florido <[EMAIL PROTECTED]> wrote:
> * Todd Slater <[EMAIL PROTECTED]> [01-10-2003 23:46]:
>
> >
> > #!/bin/bash
> > EXT=".jpg"
> > NAME=pic
> > CNT=1
> > for image in `ls /path/to/directory | sort`
> > do
> > FCNT=`printf "%02d" $CNT`
> > echo "$image ==> $FCNT-$NAME$EXT"
> > CNT=$(($CNT+1))
> > done
> > exit
> >
>
> Todd,
> That works well except for files with spaces. A file named "ab cd.jpg"
> is interpreted as two files. ab and cd.jpg
>
> Thanks again!
Matt,
You don't have to use the ls command, this will work for files with spaces
in the name and also accounts for differing case:
for image in /path/to/directory/*.[Jj][Pp][Gg]
do
FCNT=`printf "%02d" $CNT`
echo "$image" $FCNT-$NAME$EXT
CNT=$(($CNT+1))
done
Todd
Want to buy your Pack or Services from MandrakeSoft?
Go to http://www.mandrakestore.com