I have this simple python script;
def scanFolder(path="."):
foldersList = []
for name in os.listdir(path):
if os.path.isdir(name):
for innerName in os.listdir(name):
if os.path.isdir(innerName):
foldersLIst.append(innerName)
when run this script i get this error message:
Traceback (most recent call last):
File "upNew.py", line 42, in <module>
File "upNew.py", line 18, in __init__
scanFolder(path=".")
File "upNew.py", line 24, in scanFolder
for innerName in os.listdir(name):
PermissionError: [WinError 5] Access is denied: 'System Volume Information\\*.*'
How can i solve this? I'm on Windows 7, using python 3.3
Windows contains some directories that are protected, by default, against any normal user (including admins). You cannot examine these directories (with any program) unless you ask Windows for permission to access them.
So, you'll probably just want to skip the directories entirely:
try:
dirs = os.listdir(name)
except PermissionError:
print("Permission denied:", name)
continue
for innerName in dirs:
...