os.stat st_mtime problem

Alban Nona python.koda at gmail.com
Mon Aug 16 19:42:22 CEST 2010


Im stuck with this problem:
I would like to os.stat st_mtime to copy only the files that have different
modification date.
so I found something on internet using this kind of line:

if os.stat(dest).st_mtime - os.stat(src).st_mtime > 1:
    shutil.copy2 (src, dst)
So I adapted it to my script like that:

   if sys.argv[1] == 'update':
        if os.stat(localPath).st_mtime != os.stat(networkPath).st_mtime:
            os.system('xcopy /E /I /Q /Y "%s" "%s"' % (networkPath,
            print "Everything match"

localPath is equal to : "c:\test\prod\"
and networkPath to : "d:\test\prod\"

the content of this paths is another directory: "v001", where there some tga

Now I dont even know if os.stat compare the modified version of every files
contained in localPath and networkPath, or does it compare only the v001
info ?
If there a way to do it for every file ?

Thank you !
(PS: I want to avoid filecmp :p)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20100816/1a37cab0/attachment.html>

More information about the Python-list mailing list