0

I am trying to use Python 3 to list folders located on a Windows share drive. I have mounted the share in Windows explorer and I can clearly see the files exists

I am using the following code:

path = r'//UNCpath/subfolder1/subfolder2/subfolder3/'
for root, dirs, files in os.walk(path):
    print(root, dirs)
print('Hello')

but in the debugger, when I step over the for loop, it goes straight to the print('Hello') as if os.walk not finding anything. I don't get any error messages.

please let me know what I am missing, or if creds are needed.

jscriptor
  • 775
  • 1
  • 11
  • 26
  • Possibly related: https://stackoverflow.com/questions/36705257/os-walk-not-processing-subdirectories-when-using-unc-paths – snwflk Apr 16 '19 at 19:39

1 Answers1

0

I had the same error, what you said is correct, it is not finding the path, the code below is what I made as a semi project that works and is in correlation to yours: I made it as an input function so you can find a specific file/folder

s = input("Enter the directory you wish to visit")
rootdi = rootdir+"\\"
root = rootdi+s
print(root)
if os.path.isfile(root) is False:
    print("No such directory")
    quit()
Tommy Lawrence
  • 300
  • 1
  • 12