Could you tell me please, how to correctly specify the path to the network folder
from the Linux
operating system in the code?
The network folder is accessible via SMB
I use the following code to move a certain type of files:
#!/usr/bin/python3
import shutil
import os
from glob import glob
for file in list(glob(os.path.join('//192.168.10.20/NEW/test1', '*.pdf'))):
shutil.move(file, '//192.168.10.20/NEW/test2')
Process finished with exit code 0
But the files are not moved.
I tried this code on local folders - everything works fine, I think the problem is in the wrong format
of the path
to the network folder
from Linux
via SMB
, please tell me. Thanks.
CodePudding user response:
Since you're uploading to an SMB share, you need to use pysmb for instance.
NB. I don't have a SMB share available right now, so this is untested, but should point you in the right direction.
#!/usr/bin/python3
from smb.SMBConnection import SMBConnection
conn = SMBConnection(...)
assert conn.connect(ip, port)
for file in conn.listPath("NEW", path="/test1/", pattern="*.pdf"):
conn.rename("NEW", "/test1/" file.filename, "/test2/" file.filename)