[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Learning experience with BASH



Well I just had a 'learning experience' with BASH this morning.
You'd think after all these years I would know better.  I should have had a 
backup, and I should have tested the script more before deploying it against 
real data.  I would say 'Live and Learn', but I've learned this lesson 
before, just was in a hurry this morning.

What I'm trying to do is to automate my resizing of pics some more (thanks to 
the list for the help in resizing them in the first place).
What I have learned is that BASH pukes on a blank new line in a script (not a 
major problem, just an annoying mistake this morning), and that the 
underscore seems to have some special meaning in a directory/filename_tag 
listing.
I tested a simple script, appending text to the filename '$line123' and it 
worked.  I then proceded to my renaming script and ran it without testing it 
on throwaway data first.  The renaming script is called from a higher 
directory, with the directory structure './candle_name/candle_name.jpg'
It seems that BASH puked on the underscore in the second part of the directory 
structure, and my files were moved to nothing.  I have no pictures left.
So I will take more pics (wanted to get better shots any way) and use dashes 
in the name this time.

Here is my (very simple) script, any feedback on it is appreciated.
I need to add some error checking and logging to it, if anyone has any 
suggestions I'm all ears.  I want to read more on scripting, but I need to 
get this done asap, so all help is appreciated.
---------------- 
# script to resize candle pics and include resolution in name  Feb 13, 2004  
mjw
while IFS= read line
do
echo resizing $line/$line-2048x1536.jpg
jpegtopnm $line/$line-2048x1536.jpg | pnmscale -xsize 1024 -ysize 768 | 
pnmtojpeg > $line/$line-1024x768.jpg
jpegtopnm $line/$line-2048x1536.jpg | pnmscale -xsize 128 -ysize 96 | 
pnmtojpeg > $line/$line-128x96.jpg
done < soy_candle_dir
----------------

Thanks,

Matt



-- 
Littlegrassy.com      Soy Candles, Bath and Body Works
Matt Wehland          mjw@littlegrassy.com


-
To unsubscribe, send email to majordomo@silug.org with
"unsubscribe silug-discuss" in the body.