I have a Python (3.7) script that grabs a list of all files in a directory and goes through them in a for loop.
What I want to do is make sure only XML files are listed and the list of files is ordered either by creation date/time or by the number in a file name.
Currently using:
files = [f for f in os.listdir(self.config['report_directory']) if os.path.isfile(os.path.join(self.config['report_directory'], f))]
The above works fine for getting a list of files in a directory but I haven't been able to get it to list by file creation date or by the number in a file name.
Filenames example:
log_2983_report.xml
log_3948_report.xml
log_2198_report.xml
Any suggestions/help appreciated.