I have two directory with .xlsb and .msg extension i.e. for monthly and weekly. I want to get the most recent file from each folder.
I am using the same code for both, but I am getting error only for weekly folder.
self.weekly_file = [os.path.join(self.weekly_path, x) for x in os.listdir(self.weekly_path) if
x.endswith(".xlsb")]
print(self.weekly_file)
self.newest_weekly_file = os.path.basename(max(self.weekly_file, key=os.path.getctime))
print(self.newest_weekly_file)
I am getting error as:
return os.stat(filename).st_ctime
OSError: [WinError 1] Incorrect function: '\\\\docs.xyz.net.au\\sites\\K7777\\Reports\\Week\\Week - 2021-05-10.xlsb'
Even I tried the below code, this is giving only the folder name.
self.weekly_file = glob.glob(self.weekly_path)