How to automatically run the same dctimestep command based on images in different folders

Hello everyone,
I find a tutorial in Radiance website, Daylighting simulations with Radiance using Matrix-based Methods. In appendix c4, simulating a vertically adjustable shading system, It reuses the dctimestep command and the vwrays command:
First example:

Second example:
dctimestep -o results/base1-1/south%04d.hdr vmtx/base1-1/south%03d.hdr tmtx/clear.xml matrices/dmtx/base1-1.dmx skyVectors/NYC.smx
dctimestep -o results/base1-2/south%04d.hdr vmtx/base1-2/south%03d.hdr tmtx/clear.xml matrices/dmtx/base1-2.dmx skyVectors/NYC.smx
dctimestep -o results/base1-3/south%04d.hdr vmtx/base1-3/south%03d.hdr tmtx/clear.xml matrices/dmtx/base1-3.dmx skyVectors/NYC.smx

How to create bash file for loop to automatically run the same dctimestep command and vwrays command for different folders instead of typing them manually one at a time.

Thanks for your reply.
Jing Gao

This is more of a Unix question. Googling “bash looping and variables” leads to this site which offers some options.

You can also find a couple of examples of for-loops in Andy McNeil’s Five-Phase Method tutorial:
(see pages 9 and 10).
Although I didn’t succeed to do so completely, I was trying to keep the matrix-based… tutorial platform- agnostic. So, I avoided any Unix-specific commands in the tutorial as much as I could. That’s why in some places the commands are repetitive.