'How to find the newest file by name in MMMYYYY format in Python
I have folder full of xlsx files (each file representing different month) all named in the same manner: monthYYYY.xlsx (i.e. March2022.xlsx). Unfortunately files are not generated each month, so it might happen that some months are missing. From the files in the folder I am trying to find one, which was created last, based on file name (cannot use "modified on", as the files might get modified later than they are created).
I tried to loop though files, but cannot really get the way to compare current file name with what I am looking for. I also tried to loop backwards through months' names but then I got problem with how to handle switch between years and the loop might go to infinity...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|