bash question: how to do "for a in b do..." on the command line
For a web project, I need to generate PNG thumbnails from a large number of JPG files.
Alas, Code:
convert -thumbnail 150x150 *.jpg *.png Back in DOS-OS/2 days, I would have used something like this on the command line: Code:
for %1 in (".jpg") do convert -thumbnail %1 %1.png What is the quivalent in bash? I am sure this is documented in many places in the web, but it is one of those things that is hard to search for. |
i'm not sure what it is u are actually trying to do....
How do you convert it?? but #! /bin/bash for each in *.png do name=`echo $each|cut -d "." f1` convert -thumbnail 150x150 $each $name.png done the <convert> is however you mean to do the conversion. not my field sorry..... not sure what routine u are using. that's the syntax for a do expression though 'each' is the variable. you can use anything you want. this is presumming u are in the same direcotry as the files... |
This may come in handy
)It's relatively easy, I just don't want to be held responsible for f-ing up your files ;)) |
Quote:
Code:
name=`basename "$each" .jpg` |
Quote:
Code:
[...] Code:
Name : ImageMagick Relocations: (not relocatable) |
Thanks, that was what I was looking for.
Quote:
|
is my post what you were looking for?
hope it helped! back to hp-ux.... |
Got it
Ok, this does what I want:
Code:
for i in `ls *jpg`; do convert -thumbnail 150x150 $i `basename "$i" .jpg`.png; done Thanks everyone. |
All times are GMT -5. The time now is 11:37 PM. |