Looks like a python problem. You can sort the list by the date like this, but it will only work if the files are named exactly like your example. So the date can be found by splitting at _
and T
import os
from datetime import datetime as dt
path = r'C:\GIS\data'
files = [os.path.join(path, item) for item in os.listdir(path) if 'NDVI' in item and os.path.isfile(os.path.join(path, item))]
#['C:\\GIS\\data\\T43RGP_20220330T052639_NDVI.tif', 'C:\\GIS\\data\\T43RGP_20220101T052639_NDVI.tif', 'C:\\GIS\\data\\T43RGP_20221231T052639_NDVI.tif'] #Not sorted by date
files.sort(key=lambda x: dt.strptime(os.path.basename(x).split('_')[1].split('T')[0], '%Y%m%d')) #Extract the date, convert it to datetime and sort by it
#['C:\\GIS\\data\\T43RGP_20220101T052639_NDVI.tif', 'C:\\GIS\\data\\T43RGP_20220330T052639_NDVI.tif', 'C:\\GIS\\data\\T43RGP_20221231T052639_NDVI.tif']
for file in files:
#Do something
path_str
somewhere, or did you meanpath
?