I have a folder which has 586 excel files with .xls and .xlsx format, then I use shutil and I transfer the files to destination like the code below.
import shutil
import glob
for filename in glob.glob('C:\\Users\\Documents\\sample_folder\\**\\**', recursive=True):
if filename.endswith('.xlsx') or filename.endswith('.xls'):
shutil.copy(filename,"C:\\Users\\Documents\\excel-files")
Things work well and 398 files get transferred to destination successfully but I don't get the remaining files and it shows a error like
File "C:\Users\AppData\Local\Programs\Python\Python36-32\lib\shutil.py", line 121, in copyfile with open(dst, 'wb') as fdst: PermissionError: [Errno 13] Permission denied: 'C:\Users\Documents\excel-files\XYZ 1310_template.xlsx'
XYZ 1310_template.xlsx
open somewhere? – DavidG