LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 08-21-2005, 11:27 PM   #1
bd1308
LQ Newbie
 
Registered: Aug 2005
Location: Louisville, KY
Distribution: Debian Sarge
Posts: 29

Rep: Reputation: 15
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'
do
convert -resize 800x600 $img resized-$img
done

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 .JPG...so 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?
 
Old 08-22-2005, 01:27 AM   #2
maroonbaboon
Senior Member
 
Registered: Aug 2003
Location: Sydney
Distribution: debian
Posts: 1,495

Rep: Reputation: 48
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.
 
Old 08-22-2005, 06:56 AM   #3
Gint
LQ Newbie
 
Registered: Dec 2003
Location: Denver Co.
Distribution: RH
Posts: 3

Rep: Reputation: 0
The one I provided you yesterday won't work?

http://www.stokebloke.com/bash/index.php
 
Old 08-22-2005, 06:59 AM   #4
Gint
LQ Newbie
 
Registered: Dec 2003
Location: Denver Co.
Distribution: RH
Posts: 3

Rep: Reputation: 0
Quote:
Originally posted by Gint
The one I provided you yesterday won't work?

http://www.stokebloke.com/bash/index.php

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.

#!/bin/bash

for img in *.jpg;
do

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 ]
then
echo Portrait 0
convert $img -geometry 600x800! -format jpeg -quality 80 $img
else
echo Landscape 1
convert $img -geometry 800x600! -format jpeg -quality 80 $img
fi

done
 
Old 08-22-2005, 08:32 AM   #5
bd1308
LQ Newbie
 
Registered: Aug 2005
Location: Louisville, KY
Distribution: Debian Sarge
Posts: 29

Original Poster
Rep: Reputation: 15
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.
 
Old 08-22-2005, 08:37 AM   #6
bd1308
LQ Newbie
 
Registered: Aug 2005
Location: Louisville, KY
Distribution: Debian Sarge
Posts: 29

Original Poster
Rep: Reputation: 15
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?
 
Old 08-22-2005, 08:52 AM   #7
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.
 
Old 08-22-2005, 12:12 PM   #8
bd1308
LQ Newbie
 
Registered: Aug 2005
Location: Louisville, KY
Distribution: Debian Sarge
Posts: 29

Original Poster
Rep: Reputation: 15
thanks guys....

sorry to who-ever for me putting this in the wrong area...
 
Old 08-22-2005, 04:36 PM   #9
archtoad6
Senior Member
 
Registered: Oct 2004
Location: Houston, TX (usa)
Distribution: MEPIS, Debian, Knoppix,
Posts: 4,727
Blog Entries: 15

Rep: Reputation: 234Reputation: 234Reputation: 234
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.
 
Old 08-22-2005, 05:38 PM   #10
bd1308
LQ Newbie
 
Registered: Aug 2005
Location: Louisville, KY
Distribution: Debian Sarge
Posts: 29

Original Poster
Rep: Reputation: 15
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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
help with bash shell script !! taiwf Linux - Newbie 5 06-11-2006 06:07 PM
bash shell script globeTrotter Linux - Newbie 5 06-03-2004 05:07 AM
bash shell script naka0naka Linux - Newbie 7 05-28-2004 03:06 PM
BASH shell script help ewarmour Programming 8 05-24-2002 07:57 AM
bash shell script MaryM Linux - Newbie 0 02-15-2002 11:45 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

All times are GMT -5. The time now is 05:33 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration