0

I'm looking for some help to do:

1) Get the modification date/time of a file
2) Compare against the same file after a sleep of 10 minuites and if it's not different to play a beep:

import winsound
winsound.Beep(2000,500)

Any ideas?

3
  • os.stat is your friend Commented Nov 1, 2013 at 6:18
  • do you want a windows only solution or a cross platform one ? Commented Nov 1, 2013 at 6:19
  • You'd be much better off using a filesystem event to watch this so that you get notified immediately - Check out this page for an answer timgolden.me.uk/python/win32_how_do_i/… Commented Nov 1, 2013 at 6:44

1 Answer 1

3

You will be able to use below function with some modification to fit your requirements:

def getnewestfile(NetworkPath):
    DestFolder = os.getcwd()
    os.chdir(NetworkPath)
    filelist = os.listdir(os.getcwd())
    filelist = filter(lambda x: not os.path.isdir(x), filelist)
    newest = max(filelist, key=lambda x: os.stat(x).st_mtime)
    os.chdir(DestFolder)
    return newest

This function returns the newest file located at the network path as input.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.