Re: Simple way to script thumbnails



On 2011-01-13, Stan Bischof wrote:
Stan Bischof <stan@xxxxxxxxxxxxxxxxxx> wrote:
Chris F.A. Johnson <cfajohnson@xxxxxxxxx> wrote:
for j in `ls -tr *.${i} `

Not only is ls unnecessary, but it will break your script if any
filenames contain whitespace or other pathological characters. Use
parameter expansion directly:

for j in *".$i"


thanks for the style hints and whatnot- but this one is
an issue. Due to the way that the pictures are assembled it
becomes important that they show up in temporal order
and not necessarily name order. hence the ls -tr

*".$i" would not add them in temporal order.


And-- after thinking about this a little, this change
would actually break my script . In particular, if
files do not exists with a given suffix from my list then
ls returns nothing so no action is taken. *".$i"
returns *".$i" expanded, so a bogus action is taken.

For instance if there's no JPG suffix files then
I end up with an HTML line referencing *JPG

[ -f "$j" ] || continue

but defnitely thanks for the suggestions. Hadn't seen that
particular variable expansion, but it seems quite nice.

regards
Stan


--
Chris F.A. Johnson, <http://cfajohnson.com>
Author:
Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
.



Relevant Pages

  • Re: Simple way to script thumbnails
    ... but it will break your script if any ... parameter expansion directly: ... *".$i" would not add them in temporal order. ... For instance if there's no JPG suffix files then ...
    (comp.os.linux.misc)
  • Re: Problem with bash read
    ... instead, on the script, there's something unpredictable that sets key to ... Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ...
    (comp.unix.shell)
  • Re: Need script to loop fdisk
    ... A script which repeatedly calls `fdisk` while increasing the size of the ... <yes that's where the previously lost boundry WAS>. ... Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ...
    (comp.os.linux.misc)
  • Re: Which copy of the script is called?
    ... This leads to the time-wasting-trap of 'knowing' where ... the script is, working on it, only to find that your modifications ... Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress) ...
    (comp.os.linux.misc)
  • Re: shell script problem
    ... On Tue, 24 May 2005 at 14:31 GMT, Sybren Stuvel wrote: ... >> I have to make a script that will find files in current dir that ... Shell Scripting Recipes: A Problem-Solution Approach, 2005, Apress ...
    (alt.os.linux)