Python Forum
trouble with os.listdir on a network drive
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
trouble with os.listdir on a network drive
#1
everyone,

I am trying to get a list of directories and files on a network drive.
My code is:

print 'running...'

# imports
import os, sys
from os import listdir
import arcpy, os
import os
import os.path
import csv

#set root and make list
path = input ('enter directory for searching: ')
driv = os.listdir( path ) #list of folders
print driv 
maplist = []
## more code to manipulate list 


I enter: r”20.2.2.44:” for example, in that exact format. The problem is when I input the network drive (ex:r”20.2.2.44:”)(which I know has and folders file) the list (driv) returns blank. No errors are thrown. The script proceeds to the remainder of the code dedicated to manipulate the list (driv). If I enter: r”c:” the list (driv) is populated.

How do I format my input so the network drive will populate the list (driv)? Are there any other factors besides the formatting of the input that would prevent os.listdir from working on a network drive?

python version 2.7.5
IDLE version 2.7.5
OS: Windows 7 professional

Also if any of you know good sources about python on network drives, please refer me.

LCONNER
Reply


Messages In This Thread
trouble with os.listdir on a network drive - by lconner - May-22-2019, 12:58 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question How to get a removable disc type in drive Daring_T 12 970 Feb-11-2024, 08:55 AM
Last Post: Gribouillis
  open python files in other drive akbarza 1 632 Aug-24-2023, 01:23 PM
Last Post: deanhystad
  Integrating Google Drive in App Lahearle 0 440 Jul-19-2023, 05:51 PM
Last Post: Lahearle
  code to send attachments contained on the drive. stefanoste78 1 822 Oct-12-2022, 02:16 AM
Last Post: Larz60+
  access is denied error 5 for network drive mapping ? ahmedbarbary 2 1,731 Aug-17-2022, 10:09 PM
Last Post: ahmedbarbary
  Cant Access D: Drive kucingkembar 4 1,263 Jul-28-2022, 04:53 PM
Last Post: kucingkembar
  Calling exe on network drive GrahamL 4 2,468 Jan-21-2022, 12:01 PM
Last Post: GrahamL
  Failing to copy file from a network to a local drive tester_V 4 6,974 Jan-20-2021, 07:40 AM
Last Post: tester_V
  listdir on IP Adress OEMS1 3 2,833 Jul-19-2020, 06:01 PM
Last Post: bowlofred
  Nested Subdirectory within current sub on shared network drive Agregware 1 1,886 Jun-19-2019, 10:07 PM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020