From: akabou on
Hello, I have a directory in which i want to list all image .jpg
and then reduce all image to 50% using convert.

I'ev tried un small script but i've a probleme using {}.

SOURCE="$1"
type="$2"
find $SOURCE -iname "*$type" -exec convert {} -resize 50% {}.small \;

the problem is that actually i convert file and then are renamed to
REP/fil.jgp.smal

i want to rename files to REP/small_file.jpg

Thanks for you answer
From: mop2 on
On Sat, 06 Feb 2010 13:08:21 -0200, akabou <dvdmonster.fr(a)gmail.com> wrote:

> Hello, I have a directory in which i want to list all image .jpg
> and then reduce all image to 50% using convert.
>
> I'ev tried un small script but i've a probleme using {}.
>
> SOURCE="$1"
> type="$2"
> find $SOURCE -iname "*$type" -exec convert {} -resize 50% {}.small \;
>
> the problem is that actually i convert file and then are renamed to
> REP/fil.jgp.smal
>
> i want to rename files to REP/small_file.jpg


find $SOURCE -iname "*$type" |
while read f;do
echo "convert $f
etc.
etc."
done
From: Ben Bacarisse on
akabou <dvdmonster.fr(a)gmail.com> writes:
<snip>
> Thanks for your answer, but my probleme is that the pictures aren't in
> the same directory
> then the script, that why the answer of the find ~/pictures/ -iname "*
> $type"
> is ~/pictures/mypict.jpg and i want to insert a word befor mypict.jpg.
> Thanks for your answer

There are lots of ways to go about this but you might find $(dirname
$f)/small_$(basename $f) to be the key to what you want to do.

--
Ben.
From: akabou on
On 7 fév, 03:12, Ben Bacarisse <ben.use...(a)bsb.me.uk> wrote:
> akabou <dvdmonster...(a)gmail.com> writes:
>
> <snip>
>
> > Thanks for your answer, but my probleme is that the pictures aren't in
> > the same directory
> > then the script, that why the answer of the find ~/pictures/ -iname "*
> > $type"
> > is ~/pictures/mypict.jpg and i want to insert a word befor mypict.jpg.
> > Thanks for your answer
>
> There are lots of ways to go about this but you might find $(dirname
> $f)/small_$(basename $f) to be the key to what you want to do.
>
> --
> Ben.

OK, i've modified my script to enter in a loop and try do this
differently,
i've mixed mop2 and ben bacariss

here is the script.

SOURCE=$1 --> this is the directory
TYPE=$2 --> this is the file type
find $SOURCE -iname "*$TYPE" |
while read f;do
convert $f -resize 50% $(dirname $f)/small_$(basename $f)
done

it seems to ben ok, when i put an echo

akabou(a)debian:~/sp3$ ./essaie_convert.sh /home/akabou/sp3/
pictures/ .jpg
convert /home/akabou/sp3/pictures/chambre_gite.jpg -resize 50% /home/
akabou/sp3/pictures/small_chambre_gite.jpg ;
convert /home/akabou/sp3/pictures/CCF31122009_00000.jpg -resize 50% /
home/akabou/sp3/pictures/small_CCF31122009_00000.jpg ;
convert /home/akabou/sp3/pictures/IMAG0367.jpg -resize 50% /home/
akabou/sp3/pictures/small_IMAG0367.jpg ;
convert /home/akabou/sp3/pictures/IMAG0364.jpg -resize 50% /home/
akabou/sp3/pictures/small_IMAG0364.jpg ;

but when i remove echo before convert, he gives me an error.

convert: unable to open image `/home/akabou/sp3/pictures/
small_chambre_gite.jpg': No such file or directory.
convert: unable to open image `/home/akabou/sp3/pictures/
small_CCF31122009_00000.jpg': No such file or directory.
convert: unable to open image `/home/akabou/sp3/pictures/
small_IMAG0367.jpg': No such file or directory.
convert: unable to open image `/home/akabou/sp3/pictures/
small_IMAG0364.jpg': No such file or directory.

I confirm that the file are in the directory
when a paste this
convert /home/akabou/sp3/pictures/chambre_gite.jpg -resize 50% /home/
akabou/sp3/pictures/small_chambre_gite.jpg ;

to the terminal no erro and the file is resized.

????????????

does anyone have an idea.

Thanks
From: akabou on
On 7 fév, 01:19, mop2 <inva...(a)mail.address> wrote:
> On Sat, 06 Feb 2010 13:08:21 -0200, akabou <dvdmonster...(a)gmail.com> wrote:
> > Hello, I have a directory in which i want to list all image .jpg
> > and then reduce all image to 50% using convert.
>
> > I'ev tried un small script but i've a probleme using {}.
>
> > SOURCE="$1"
> > type="$2"
> > find $SOURCE -iname "*$type" -exec convert {} -resize 50% {}.small \;
>
> > the problem is that actually i convert file and then are renamed to
> > REP/fil.jgp.smal
>
> > i want to rename files to REP/small_file.jpg
>
> find $SOURCE -iname "*$type" |
> while read f;do
> echo "convert $f
> etc.
> etc."
> done

thanks for the loop