File size: 384 Bytes
38ae436
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14

import os
import logging

def get_latest_modified_file(directory):
    logger = logging.getLogger(__name__)
    
    files = [os.path.join(directory, f) for f in os.listdir(directory)] 
    if not files:
        logger.log(logging.WARNING, f'No files found in the directory: {directory}')
        return None
    latest_file = max(files, key=os.path.getmtime)

    return latest_file