Register Virtual Stack Slices - Batch Run on Multiple Folders with Jython Script

I need help making the jython code helping me registering individual IHC images generated by a multiplex IHC methodology that generates multiple marker images from a single section.
I have more than hundred folders and each folder have 10 tif images from the same area of the tissue section. I am using this jython perfectly for individual images but can anybody help me on modifying it to loop through all the folders? The problem is target image name changes in each folder due to case ID.

Thanks

from register_virtual_stack import Register_Virtual_Stack_MT
 
# source directory
source_dir = "/path/to/source/"
# output directory
target_dir = "/path/to/target/"
# transforms directory
transf_dir = "/path/to/transforms/"
# reference image
reference_name = "reference_image"
# shrinkage option (false)
use_shrinking_constraint = 0
 
p = Register_Virtual_Stack_MT.Param()
# The "maximum image size":
p.sift.maxOctaveSize = 1024
# The "inlier ratio":
p.minInlierRatio = 0.05
 
Register_Virtual_Stack_MT.exec(source_dir, target_dir, transf_dir, 
reference_name, p, use_shrinking_constraint)