Usually, if you batch process the data, you need to get the image data path under all file directories, and then process it scene by scene.
The method of obtaining is as follows:
import os
items = os.listdir("G:\mypython3\gdal\data")
newlist = []
for names in items:
if names.endswith(".img"):
newlist.append("G:\mypython3\gdal\data"+"\\"+names)
Official help for OS Python package:
Or you can:
os.chdir('G:\mypython3\gdal\data\mosaic')
in_files = glob.glob('*.tif')
print(in_files)