<html><head><style type='text/css'>p { margin: 0; }</style></head><body><div style='font-family: arial,helvetica,sans-serif; font-size: 12pt; color: #000000'>By the way, there's no need for the `ls ...`. You can just put:<div><br></div><div>for i in *.jp2</div><div>do ...<br><br>You get the same results, and you avoid creating a subshell. </div><div>Well, you get a slightly different result when there are no *.jp2 files: ls throws an error vs i=*.jp2.</div><div><br><hr id="zwchr"><div style="color:#000;font-weight:normal;font-style:normal;text-decoration:none;font-family:Helvetica,Arial,sans-serif;font-size:12pt;"><b>From: </b>"Wolf Halton" <wolf.halton@gmail.com><br><b>To: </b>"Atlanta Linux Enthusiasts" <ale@ale.org><br><b>Sent: </b>Wednesday, February 20, 2013 11:57:28 AM<br><b>Subject: </b>Re: [ale] Bulk jpg Thumbnail production from 137000 jp2 files??<br><br><div dir="ltr">This is what I got to work, following Pete's lead, this time<br><br>#!/bin/bash<br><br>for i in `ls *.jp2`<br>do<br> file=`basename $i`<br> #echo $file<br> SUFF="jp2"<br> slim=${file%.$SUFF}<br>
#slim=`echo $file ${file%.$SUFF}`<br> <br> #echo "$slim is the stub"<br> suffix='jpg'<br> <br> convert $i -resize 7% $slim.$suffix<br> echo "$slim.$suffix is created"<br>
<br>done<br><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Feb 20, 2013 at 10:19 AM, JD <span dir="ltr"><<a href="mailto:jdp@algoloma.com" target="_blank">jdp@algoloma.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Here's a script that I use to make images smaller for internet publishing.<br>
Files cannot have spaces in their names since that is the delimiter, but ...<br>
just change "-opt" into "-tn" and change the convert options for your needs.<br>
<br>
No need to leave bash for file suffix handling. This should be much quicker. But<br>
there are at least 1000 different ways to skin this problem. ;)<br>
<br>
#########################################<br>
#!/bin/bash<br>
QUAL=30<br>
<br>
for img in "$@"; do<br>
NEW=${img/%.???/-opt.jpg}<br>
echo " Working on $img ..."<br>
convert -quality $QUAL "$img" "$NEW"<br>
done<br>
#########################################<br>
<div class="im HOEnZb"><br>
On 02/20/2013 10:08 AM, Wolf Halton wrote:<br>
> Pete:<br>
> That looks like it would work.<br>
> I will test in my sample folders.<br>
> I absolutely do not want to handle each file manually. :-)<br>
><br>
><br>
> On Wed, Feb 20, 2013 at 9:58 AM, Pete Hardie <<a href="mailto:pete.hardie@gmail.com" target="_blank">pete.hardie@gmail.com</a><br>
</div><div class="im HOEnZb">> <mailto:<a href="mailto:pete.hardie@gmail.com" target="_blank">pete.hardie@gmail.com</a>>> wrote:<br>
><br>
> shell script, not necessarily error free:<br>
><br>
> for i in `ls *.jp2'<br>
> do<br>
> file=`basename $i`<br>
> suffix='suffix'<br>
> convert $i <options> $file.$suffix<br>
> done<br>
><br>
> man basename for all the fun options - it can get you the path, a part<br>
> before the '.', a part after the '.', etc<br>
><br>
><br>
</div><div class="HOEnZb"><div class="h5">_______________________________________________<br>
Ale mailing list<br>
<a href="mailto:Ale@ale.org" target="_blank">Ale@ale.org</a><br>
<a href="http://mail.ale.org/mailman/listinfo/ale" target="_blank">http://mail.ale.org/mailman/listinfo/ale</a><br>
See JOBS, ANNOUNCE and SCHOOLS lists at<br>
<a href="http://mail.ale.org/mailman/listinfo" target="_blank">http://mail.ale.org/mailman/listinfo</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Wolf Halton<br>This Apt Has Super Cow Powers - <a href="http://sourcefreedom.com" target="_blank">http://sourcefreedom.com</a><br>Open-Source Software in Libraries - <a href="http://FOSS4Lib.org" target="_blank">http://FOSS4Lib.org</a><br>
Advancing Libraries Together - <a href="http://LYRASIS.org" target="_blank">http://LYRASIS.org</a><br>Apache Open Office Developer <a href="mailto:wolfhalton@apache.org" target="_blank">wolfhalton@apache.org</a><br>
</div>
<br>_______________________________________________<br>Ale mailing list<br>Ale@ale.org<br>http://mail.ale.org/mailman/listinfo/ale<br>See JOBS, ANNOUNCE and SCHOOLS lists at<br>http://mail.ale.org/mailman/listinfo<br></div><br></div></div></body></html>