Determining when a file has finished copying

Ethan Furman ethan at stoneleaf.us
Mon Jul 14 23:05:39 EDT 2008


Michiel Overtoom wrote:
> Ethan wrote:
> 
>> One more option may be to attempt to rename 
>> the file -- if it's still open for copying, that will fail; 
>> success indicates the copy is done.  
> 
> Caveat -- this is dependent on the operating system!
> 
> Windows will indeed not allow you to rename or delete a file that's still
> open for writing by another process, at least not when the file is on a
> local NTFS filesystem, but don't count on this on Unix or networked
> filesystems.  There you can easily rename, move or delete a filename from a
> directory whilst other processes still write to it. After all, a directory
> is nothing else than a list of filenames which map to certain inodes.

Very good point.  Thanks.
~Ethan



More information about the Python-list mailing list