-   Linux - Hardware (
-   -   Bash Shell script (

bd1308 08-22-2005 12:27 AM

Bash Shell script
hello folks, i run debian sarge on a dual pentium pro system....

i was trying to use the "convert" command from the imagemagick package to resize the pictures from whatever size they were to 800x600 size.

I found this online:

for img in 'ls *.jpg'
convert -resize 800x600 $img resized-$img

unfortunately, this did not work. I tried single-quotes and double-quotes and neither worked.

this was entered line per line at a bash prompt (i've entered them in successfully before)
and it did not work

all files end in either .jpg or i am assuming that I would have to do this script twice....

does anybody have any input on what could be wrong with the script?

maroonbaboon 08-22-2005 02:27 AM

Not exactly hardware :) but I think the original script probably had backquotes:

for img in `ls *.jpg`

But it seems easier to just use

for img in *.jpg *.JPG

as the first line.

Gint 08-22-2005 07:56 AM

The one I provided you yesterday won't work?

Gint 08-22-2005 07:59 AM


Originally posted by Gint
The one I provided you yesterday won't work?

Specifically, the author wrote:

Converting sources to website size

Before I can convert all the images I manually rotate any pictures which need it using

convert -rotate 90 image.jpg image.jpg

All my cameras are over 5 megapixel and the jpgs are very large. I always scale the image to be 800x600 or 600x800. The following script converts images which are Landscape to 800x600 and Portrait to 600x800.


for img in *.jpg;

export height=`identify -format %h $img`
export width=`identify -format %w $img`
let ratio=$width/$height

echo Image $img = [ $width x $height ] = $ratio

if [ $ratio == 0 ]
echo Portrait 0
convert $img -geometry 600x800! -format jpeg -quality 80 $img
echo Landscape 1
convert $img -geometry 800x600! -format jpeg -quality 80 $img


bd1308 08-22-2005 09:32 AM

backquotes!!! I see them....

about the category, I was going to ask a question about my old thinkpad soundcard not working under sarge...but i decided that i didnt care.

bd1308 08-22-2005 09:37 AM

thanks gint...that ended up working.

then i tried the one with the backquotes and it worked too.

thanks :)

gint, do you have a recommendation for PHP books...or was it somebody else who said that?

MensaWater 08-22-2005 09:52 AM

FYI: The backticks tell it to execute the command line inside them FIRST then do the rest of the command line.

Also `ls *.jpg *.JPG` would do it all in one for loop.

You can put quite a lot into the backticks - say you wanted to see only the files created in 2004:

`ls -l *.jpg *.JPG |grep " 2004 " |awk '{print $NF}'`

This tells it to do full directory listing, grep for only those items that have 2004 with whitespace around it (helps to eliminate 2004 embedded in the filesize name) then says to print only the last field which is the file name.

bd1308 08-22-2005 01:12 PM

thanks guys....

sorry to who-ever for me putting this in the wrong area...

archtoad6 08-22-2005 05:36 PM

If you would like a moderator to move it, you are allowed to report it yourself -- you don't have to wait for someone else to do it.

Just click on the "Report this post to a moderator" in your own post.

bd1308 08-22-2005 06:38 PM

let me make this applicable to the area then...

i have a 380XL IBM thinkpad (old--P133)

cs1432 or some old soundcard....

I installed debian on it...and the blasted soundcard will not load...

i tried OSS and alsaconf, but i get nothing....actually alsaconf never found the card...i had to manually configure it in some config file....and it *still* didn't work.

any clues?

All times are GMT -5. The time now is 01:28 AM.