I am using a watchdog module to move video files to a different folder. But the problem is the move process starts as soon as the file is created and is still under copy process from its origin location. To overcome this, I did a file size check, but windows is not refreshing the filesize in real time and hence the file size check is not proving to be useful.
Is there another way to check if the file is fully copied (maybe if file can be read/opened?) prior to moving the file. I tried the code below but to no avail.
while True:
try:
with open(os.path.basename(event.src_path)) as f:
s = f.read()
print ("can read the file now")
except IOError:
print ("cannot read the file")
#shutil.move operation here
Any ideas will be appreciated.