1. 程式人生 > >python 復制多個文件到指定目錄(基於python 3.X)

python 復制多個文件到指定目錄(基於python 3.X)

__name__ std lena import print tex post res 目錄

import os
import shutil



def copyPDF():
addressPDF = "E:/totally/FinancePDF/"

f_list = os.listdir(addressPDF)
n=0
for fileNAME in f_list:

if os.path.splitext(fileNAME)[1] == ‘.pdf‘:
n += 1
oldname = u"E:\\totally\\FinancePDF\\" + fileNAME
newname = u"E:\\totally\\Finance_PDFfile\\" + fileNAME
shutil.copyfile(oldname, newname)
print(str(n)+‘.‘+‘已復制‘+fileNAME)

if __name__ == ‘__main__‘:
copyPDF()

python 復制多個文件到指定目錄(基於python 3.X)