I have images in a sub-folder. Let's the folder images
I have a python program which will take image arguments from the folder one by one, the images are named in sequential order (1.jpg , 2.jpg, 3.jpg and so on).
The call to the program is : python prog.py 1.jpg
What will be a shell script to automate this ?
Please ask for any additional information.
3 Answers 3
Try this from the folder that contains images/:
for i in images/*.jpg; do
python prog.py $i
done
1 Comment
{} button in the Formatting Toolbar near Bold and Italic. Or you can put 4 spaces at the start of each line.You could do them all in parallel very simply with GNU Parallel like this:
parallel python prog.py ::: images/*.jpg
Or, if your Python writes to the current directory:
cd images
parallel python prog.py ::: *.jpg
Comments
cd IMG_DIR
for item in [0-9]*.jpg
do
python prog.py $item
echo "Item processed : $item"
done
You can also pass image dir as a shellscript argument
2 Comments
$item needs to get quoted when passed to python, otherwise it would break if the image name has embedded spaces.for item in [0-9]*.jpg
forloop for running python script for all files.