Mount Windows smb shares on a Mac using Python

I think, with the help of Tony Williams, I have figured it out. My mount a Windows smb share python script:

import os
directory = "/Users/user.name/foldername"
if not os.path.exists(directory): os.makedirs(directory)
os.system("mount_smbfs //user.name:password@server/servershare ~/foldername")

This will check whether a local folder called foldername exists and create it if doesn't. It will then mount the smb share into it using a defined username/password.


I would suggest you start setting up networking using System Preferences.

Go to System Preferences/Network/Wi-Fi (or Ethernet)/Advanced/WINS and set your Workgroup to match the Windows Workgroup

Then go to Finder/Go/Connect to Server

Try to connect using smb://servername

Once you can connect you can try to automate.