![](/img/trans.png)
[英]shutil.move() - error message that the destination file does not exist
[英]Using shutil.move(), how do i move the file to destination folder and keep the file in the source folder at the same time
此 function 从源文件夹中获取 pdf/pptx 文件并将其放置在目标文件夹中。 我希望 function 这样做,但也要保留源文件夹中的文件。 此外,如果文件已经存在于目标文件夹中,他们是否可以通过编程方式将新文件保存在现有文件之上?
#function to place files in their respective folders once we know that all clientIDs are accounted for
def placeFiles():
for a, p in zip(clientInventory, folderName):
shutil.move(source + quarter + str(a) + '.pdf', destination + str(p) + '\\' + str(a) + ' Performance\\')
shutil.move(source + quarter + str(a) + '.pptx', destination + str(p) + '\\' + str(a) + ' Performance\\')
您可以为此使用shutil.copy()
。 它将文件从源复制到目标,并将原始文件保留在源中。 我还相信,如果目标中已经有一个具有该名称的文件,它将用您正在复制的文件覆盖该文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.