Re: [SLUG] Bash script

From: Kwan Lowe (kwan@digitalhermit.com)
Date: Tue May 24 2005 - 01:38:39 EDT


>
> Kwan,
> You state it runs OK. Doesn't for me. I get thos line 35 thru line 41
> "command not found" messages. Then you suggest, as per the following:
> #########################################################################
>
>>>echo Running $0
>>>echo
>>>
>>>COUNT=0
>>
>> Unused var?
>
> Don't know what you mean by that.

I didn't recall seeing COUNT referenced anywhere else in the script.
Since it's set, but not used it's an unused VAR.

>
>
>>>cd $FROM_DIR
>>>for i in *.$FROM; do
>>>
>>> echo $1
>>> if [ ! -e "$TO_DIR/$i" ] # Process only files not already
>>>done
>>> then
>>> echo Converting $i... with $CONVERT_OPTIONS
>>> convert $CONVERT_OPTIONS $FROM_DIR/$i
>
> $TO_DIR/${i%%$FROM}$TO
>
>
>> As a general practice I tend to use ${VARNAME} instead of just
>>$VARNAME. Won't matter here, but can help with debugging. Instead of
>>the above notation, you can also generate the filenames with:
>
> Don't know what you mean by that neither. I don't see anything in the
> script with $VARNAME

I used VARNAME as just an example. You can specify a variable as either
$VARNAME or ${VARNAME}. The latter syntax is very useful for isolating
the variable itself. You can do something like 'echo ${VARNAME}1' and it
will print ${VARNAME} followed by 1. E.g., if VARNAME = Magoo, then
'echo ${VARNAME}1' will print:
    Magoo1

If you use the other syntax, 'echo $VARNAME1', then the script will
assume that the variable is called VARNAME1 and print nothing, since
VARNAME1 doesn't exist.

>> BASENAME = `echo ${i} | sed -e 's/.jpg$//'`
>
> Is this a replacement line for what is there? or is it added in the
> script?

Yes, this is a replacement. This will use the "sed" utility to strip off
the .jpg suffix. It's not necessarily better than your version, but a
little more portable.

>
>
>>Then:
>
>
>> convert ${CONVERT_OPTIONS} ${FROM_DIR}/${i}
>
> ${TO_DIR}/${BASENAME}.>${TO}
>
>
>>(Above line should not wrap)
>
-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 19:07:25 EDT