Jump to content

Python- Enumerating files from a network directory (Ubuntu)


Recommended Posts

I've been searching how to enumerate files from a network directory for a couple hours now with no luck. I need to be able to do this with Python for an application that I am working on.

Methods tried so far-

import os
>>> print os.path.splitext

from os import listdir
>>> from os.path import isfile, join
>>> onlyfiles = [f for f in listdir("smb:///dw_fileserver/") if isfile(join("smb:///dw_fileserver/", f))]

os.walk("smb:///dw_fileserver/")

 

 

I don't think that anyone will be able to help, but I'm taking a shot in the dark at this point. I'm using Samba to connect to the file sharing network. There's either no answer to this question or I'm searching the wrong question. GRRRRRRR rawr!

Link to comment
Share on other sites

Why three / ?

 

Did you tried:

os.walk("smb://dw_fileserver/")

or

os.walk("smb://dw_fileserver")

?

 

I was using smb path on mine MacOS X, and I could swear it had smb://192.168.0.2/ ....

But maybe mine memory is failing at middle of night.

 


Tried using IP address instead of name?

Link to comment
Share on other sites

BTW, on Windows when we use from command line:

dir "\\192.168.0.2\" there is error "name of file, volume, or directory incorrect".

But if we will use f.e. dir "\\192.168.0.2\SharedDocs", it's working as expected.

Basically directory listing functions can't work to list volumes.

Not sure about Unix implementation.

You might search google for "list volumes linux" or so.

Edited by Sensei
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.