On Sun, Dec 13, 2009 at 04:36:47PM +1100, david wrote:
> $ for i in *.tif ; convert $i $i.jpg; done
> $ for i in $i.jpg ; do mv $i `echo $i | sed s/.tif//`; done
>
> Apart from specific examples, where do I look in the bash book for a better
> way to remove the <.tif> part of the output filename, or other such
> substitutions?
See the section called EXPANSION, and in particular, Parameter
Expansion. The one you want is:
${parameter/pattern/string}
The pattern is expanded to produce a pattern just as in pathname
expansion. Parameter is expanded and the longest match of
pattern against its value is replaced with string. If Ipattern
begins with /, all matches of pattern are replaced with
string. Normally only the first match is replaced. If
...
To remove ".tif" from $i in your second loop, use ${i/.tif/}. To run
convert and set the correct outout filename as the same time, you can do
this:
$ for i in *.tif ; convert $i ${i/%.tif/.jpg}; done
John
--
We Europeans tend to prefer our cars like our women: small, curvy,
responsive and not too thirsty. If North Americans prefer Eastern Block
female shot-putters with advanced alcoholism, well, it takes all types.
-- Alan Bellingham
--
SLUG - Sydney Linux User's Group Mailing List - http://slug.org.au/
Subscription info and FAQs: http://slug.org.au/faq/mailinglists.html