Python:PermissionError:[Errno 13]权限被拒绝:'D:/ Documents / 1'

Error I am trying to read the sub folders in a folder (D:/Documents/), open the word documents in those sub folders, count the number of lines and if the count is greater than 2 I would like to move the sub folder into a respective sub folder of a destination folder named (D:/copied-folders/) with the same file names. But I am being thrown an error (PermissionError: [Errno 13] Permission denied: 'D:/Documents/1'). Below is the code written in Jupyter workbook:::

import os
import shutil
import sys
import bs4
import requests
count = 0
src = 'D://Documents/'
dest = 'D://copied-folders//'
for root, dirs, files in os.walk('D:/Documents/', topdown=False):
    #for name in files:
        #os.remove(os.path.join(root, name))
    for name in dirs:        
        #print(os.path.join(root, name))
        dir = os.path.join(root, name)
    for name in files:
        print(os.path.join(root, name))
        #count = 0
        for line in open(os.path.join(root, name), encoding='latin-1'):
            count += 1
            pos = 'out'
        print("Line Count:", count)
        if count > 2:
            #stat = os.close(1)
            #print(stat)
            #shutil.copy(name, dest)
            #path1 = os.path.join(root)
            #print(os.path.basename(path1))
            #os.path.relpath('D://Documents/')
            path = os.path.join(root)
            print(os.path.basename(path))
            #p = os.path.basename(path)
            shutil.copyfile(path, dest)
        else:
            continue

还附带了我遇到的错误的屏幕截图。请帮我解决一下这个。我们对此有紧迫感。我是python的新手,从过去的2天开始挠头。任何帮助表示赞赏

评论