Please, DO NOT USE QUOTE TAGS around code.
Use
[code][/code] tags around your code and data, to preserve formatting and to improve readability. And in this case to keep the page from side scrolling.
You've been here for almost 3 years, so you should know this by now.
Quote:
The variable I chose was nanosecond increment of time so I think thats why I get away withut the loop.
|
No. Think about how the shell reads this command:
Code:
convert /tmp/*.jpg -resize 200X100 /tmp/$(date +%N).jpg
First, it breaks the line up into individual "words", then it does any parameter and command expansions for each word, and then finally the expanded command is executed. So the
$(..) expansion is parsed only once, and convert is executed with only that single filename as its output argument.
You have to run a separate command for each input file in order to give them unique names.
convert does have quite a few options of its own for controlling input and output though, so you might want to research its features.
http://www.imagemagick.org/script/convert.php
http://www.imagemagick.org/Usage/
Not to mention that there's a good collection of scripts already available. Perhaps one of them will meet your needs.
http://www.fmwconcepts.com/imagemagick/index.php
Code:
for X in $(ls -l /tmp/[0-9*]*.jpg)
Sigh... How many times does this have to be repeated?
Do not parse
ls for filenames!
http://mywiki.wooledge.org/ParsingLs
Do not read lines with
for!
http://mywiki.wooledge.org/DontReadLinesWithFor
Besides, if you use "
ls -l", you aren't getting just the filename, but all the metadata too. I don't think you want that.
To operate on a list of filenames, just use a
globbing pattern directly. A
for loop can handle globbing matches safely.
Code:
for X in /tmp/[0-9*]*.jpg ; do
( I'm not sure about that globbing pattern either, BTW, unless you expect some of the filenames to start with a literal "*" character. Did you perhaps want "
/tmp/[0-9]*.jpg"? )
For more complex file matching use
find of course, and if the action is too complex for
-exec or
xargs, switch to using a
while+read loop. Again, don't use a
for loop to read the output of a command.
Be sure to use the
-print0 option when possible, also.