简体   繁体   中英

Python shutil.move copies endlessly

I made a script that reads pdf-files from a src-folder, gets some info from the file and then renames the file and moves it to another location. This is done every 5 seconds.

Since the src and dest are on different disks I use shutil.move instead of os.rename.

Because src and dest are on a different disk shutil.move wil instead copy and delete the source file.

The script works fine, but sometimes there are problems with permissions in the source folder. This keeps the source file in the source folder and is copied endlessly because the source file can't get deleted.

How can I work around this? Since I don't keep the name of the original pdf-files I don't know how to solve this.

在此处输入图像描述

Have you considered keeping track of when you last moved files, and then only moving source files with later modification timestamps?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM