I am trying to list all shared folders on a Synology NAS with Python.
So let's say I want a list of every folder on \\DISKSTATION
E.g.: public, homes, movies, etc
Is that possible?
Thanks for your help!
I am trying to list all shared folders on a Synology NAS with Python.
So let's say I want a list of every folder on \\DISKSTATION
E.g.: public, homes, movies, etc
Is that possible?
Thanks for your help!
Why not use pysmb
?
pip install pysmb
To list share contents:
from smb.SMBConnection import SMBConnection
conn = SMBConnection('username', 'password', 'local_NetBIOS_name', 'remote_NetBIOS_name')
conn.connect('ip_address')
results = conn.listPath('share_name', '/optionally/some/subfolder')
for x in results:
print x.filename
Will output:
.
..
dir1
dir2
file1
file2
from smb.SMBConnection import SMBConnection
conn = SMBConnection('username', 'password', 'local_NetBIOS_name', 'remote_NetBIOS_name')
conn.connect('domain address')
folders = conn.listPath('share_name', '/relative/subfolder')
for folder in folders:
print folder.filename
conn.connect can also make use of domain address like xyz.com
conn.connect('xyz.com')
if you can access your NAS folder directly (without any further authentication), you may try to run python:
import os
os.listdir(r'\\DISKSTATION')
it will print out the subfolders in \\DISKSTATION
. if you want to find all subfolders, you may follow: Getting a list of all subdirectories in the current directory