Is there a Python-based library/script that can check the last date at which a list of file/folders was modified and create a Markdown document out of that?

The use case is that I regularly back up a few folders, and I want to have a status page which I can store on GitHub and others can view to have an idea of when a folder was last backedup.

1 Answer 1


you can use something like

import os
import datetime

directory = raw_input('Enter a directory address: \n')
foldercheck = raw_input("Do you want to print folder contents also? Y/N ?\n")
log = open ("log.txt", "w")
def listing(strn):
for f in os.listdir(strn) :

    #print (f, datetime.datetime.fromtimestamp(os.path.getmtime(f)))
    pathname = os.path.join(strn, f)
    prevpathname = (strn)
    if (os.path.isfile(pathname)):    
        log.write (str(pathname) + "\t last modified:\t" + str(datetime.datetime.fromtimestamp(os.path.getmtime(pathname))) + "\n")
    if(foldercheck == "Y"):
            log.write(str(pathname) +  "\tlast modified:\t" + str(datetime.datetime.fromtimestamp(os.path.getmtime(pathname))) + "\n")
    if(os.path.isdir(pathname)) :
        #print("current path:\n"+ pathname)
        #print("changing path back to:\n"+ prevpathname)


as far as markdown you can edit the log.write file in markdown syntax and instead of saving it as .txt use .m

checked on win10 python 2.7.11 Hope it helps

  • 1
    Afraid this doesn't meet the requirements fully: 1) no markdown, 2) incomplete (OP writes about "a few folders" – and thus obviously wants a script that covers them all). The basic idea might fit – but for an answer, it needs some enhancement :)
    – Izzy
    Jun 20, 2016 at 22:04
  • markdown part user can edit it himself the way he wants and for the complete list of files along with folders i have updated the complete code. checked on windows 10
    – warl0ck
    Jun 21, 2016 at 15:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.