Python – check if a file is ‘complete’ (with python)


is it possible to check if a file is done copying of if its complete using python?
or even on the command line.
i manipulate files programmatically in a specific folder on mac osx but i need to check if the file is complete before running the code which makes the manipulation.

Best Solution

There's no notion of "file completeness" in the Unix/Mac OS X filesystem. You could either try locking the file with flock or, simpler, copy the files to a subdir of the destination directory temporarily, then move them out once they're fully copied (assuming you have control over the program that does the copying). Moving is an atomic operation; you'll know the file is completely copied once it appears at the expected path.