Is there a way to get the date a file or folder was last modified into python?

Recommended Answers

All 3 Replies

There certainly is a way!

import os

path = "path here"
seconds = os.path.getmtime(path)
print time.strftime('%Y-%m-%d %H:%M', time.localtime(seconds)
#it will output the time last modified!

It also needs

import time

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.