os.stat st_mtime problem
MRAB
python at mrabarnett.plus.com
Mon Aug 16 14:35:08 EDT 2010
Alban Nona wrote:
> Hello,
>
> 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,
> localPath))
> else:
> 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 files.
>
> 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 ?
>
os.stat doesn't compare anything, it just returns info about a single
file or directory.
More information about the Python-list
mailing list