From: akabou on 7 Feb 2010 04:58 On 7 fév, 10:48, akabou <dvdmonster...(a)gmail.com> wrote: > 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 OK, i've find the problem i had a space after basename$f), convert $f -resize 50% $(dirname $f)/small_$(basename $f) \; thanks you very much to all.
From: mop2 on 7 Feb 2010 05:03 On Sun, 07 Feb 2010 07:48:30 -0200, akabou <dvdmonster.fr(a)gmail.com> wrote: > while read f;do > convert $f -resize 50% $(dirname $f)/small_$(basename $f) > done dirname and basename are external commands, and you dont need them: while read f;do echo convert $f -resize 50% ${f%/*}/small_${f##*/};done I don't know if this is true for your shell
From: Chris F.A. Johnson on 8 Feb 2010 07:09 On 2010-02-07, mop2 wrote: > On Sun, 07 Feb 2010 07:48:30 -0200, akabou <dvdmonster.fr(a)gmail.com> wrote: > >> while read f;do >> convert $f -resize 50% $(dirname $f)/small_$(basename $f) >> done > > > dirname and basename are external commands, and you dont need them: > > while read f;do echo convert $f -resize 50% ${f%/*}/small_${f##*/};done > > I don't know if this is true for your shell It is part of the standard Unix shell. -- Chris F.A. Johnson, author <http://shell.cfajohnson.com/> =================================================================== Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress) ===== My code in this post, if any, assumes the POSIX locale ===== ===== and is released under the GNU General Public Licence =====
From: Sven Mascheck on 8 Feb 2010 15:42 mop2 wrote: > dirname and basename are external commands, and you dont need them: > while read f;do echo convert $f -resize 50% ${f%/*}/small_${f##*/};done Footnote: This looks reasonable for "real" file paths, e.g., /dir/dir/file. Keep in mind, though, that the external utilities try to catch all the corner cases. For example: - an argument without any / is equivalent to ./argument - basename simply yields the last element of a path, which might be a directory. This applies even with a trailing slash. - be robust against consecutive slashes anywhere - results make sense even if the argument is quite short, dir/, ., /, /., ./, etc. - empty argument is equivalent to . (in some implementations) This requires some script glue around the above parameter substitutions.
First
|
Prev
|
Pages: 1 2 Prev: Ya didnae ha' te use brackets. Be curly, Jimmeh! Next: basic loop assistance |