Jump to content

Python- Enumerating files from a network directory (Ubuntu)

Featured Replies

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!

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?

  • Author

I haven't tried that. I was looking into smbclient to help with the process but there is no documentation. Every example that I've found are not thorough enough. Looks like I got some homework to do.

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

Archived

This topic is now archived and is closed to further replies.

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.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.