I am developing code in python that should compare the date of the files in the folder to the current date. But I Can't get dates of the files can you help me ?
Asked
Active
Viewed 108 times
0
-
3The date they were created? The date they were last edited? What have you been trying? – TayTay Dec 03 '20 at 18:47
-
1`But I Can't get dates of the files` why not? What issues did you run into? – Random Davis Dec 03 '20 at 18:49
1 Answers
0
You could iterate through the files with something like this:
import os.path, time
print("Created: %s" % time.ctime(os.path.getctime("filename.txt")))
to get the dates of the files.
to get the current date you could use
from datetime import datetime
now = datetime.now()
current_time = now.strftime("%H:%M:%S")
print("Current Time =", current_time)
and then compare them in the format you want

clanky1997
- 82
- 6