Im trying to create a function where if file modified, then perform task. I am able to do this if a file exists by doing -
import os
file_path = 'C:/Hi/'
if os.listdir(file_path):
do xyz
But how can i do xyz based on if a files date was modified?
os.path.getmtime(file_path)
Only gets the time but cant be used in my if statement
Try:
The
ifcondition detects a file modification within the specified time span, preferably since the last check for modifications.