1

I saw a question on here somewhat like mine, but the solution there did not work.

My code is:

for filename in os.scandir('\\\\network_drive\\folder\\folder\\folder\\'):
    print(filename)

The error is:

FileNotFoundError: [WinError 67] The network name cannot be found:
    '\\\\network_drive\\folder\\folder\\folder\\'

The network drive's path is definitely correct (I copied/pasted straight out of Windows Explorer's address bar). Am I syntactically screwing up or is this possibly a permissions problem via Active Directory? I'm seriously not understanding what I'm screwing up.

Update: I can't even map the network folder to a drive on my machine, leading me to think this is an AD issue. I've contacted my IT department to see if they can help resolve the issue.

Update: It was an AD issue; IT team fixed the issue, just forgot to update... 3 years ago.

dmcoding
  • 332
  • 4
  • 18

2 Answers2

1

The following should work:

os.scandir('//network_drive/folder/folder/folder/')

See this answer to an earlier question.

Also, sometimes this may work

  with os.scandir('//network_drive/folder/folder/folder/') as it:
      for fnames in it:
          ...
s-m-e
  • 3,433
  • 2
  • 34
  • 71
  • It does not work. Just tried it out. It's looking more and more like an Active Directory issue. I can't even map that network drive to a drive on my desktop. – dmcoding Dec 19 '17 at 16:06
  • 1
    @dmcoding, if you are unable to map then you need to try that because your code looks right. – Chetan_Vasudevan Dec 19 '17 at 16:08
0

Have you tried using the below? It worked for me.

os.listdir('\\network_drive\c$\folder\folder\folder')
  • i haven't programmed in python in like a year and a half. i have no idea if this is correct or not because the script was abandoned/replaced and i don't even work there anymore. – dmcoding Jun 17 '21 at 21:02