0

Is it possible to pickup the latest file in my folder?

I currently type in the month to pickup the file of choice, However I am not sure how to pickup the latest modified file?

I am confused trying to use max since the date I Input I use is used twice and want to use it to pickup latest smalldate and then pickup the file in that folder.

( {smalldate} for parent folder and {monthyear} for a part of the file name)

monthyear = input("Enter Full Month and Year: ")   #Ie August 2021
smalldate = pd.to_datetime(monthyear, format="%B %Y").strftime("%b %Y")
userid = str(os.getlogin())
gco = (rf"C:\Users\{userid}\OneDrive\Report\{smalldate}\Detail Report - {monthyear}.xlsx") 
Jonnyboi
  • 505
  • 5
  • 19
  • Does this answer your question? [How to get the latest file in a folder?](https://stackoverflow.com/questions/39327032/how-to-get-the-latest-file-in-a-folder) – Karl Oct 15 '21 at 17:31
  • If you are having problem with `max`, post _that_ code, not the other stuff that works. – tdelaney Oct 15 '21 at 17:40

0 Answers0