1

I am automating some of my reports and require the ability to upload files to a SharePoint directory to which I have access. The goal would be to have this script run via Task Scheduler (which I already know how to set up).

Not sure where to start with this, but I have seen a few threads trying to do this using the sharepoint and requests modules, but still somewhat stuck.

Any help is much appreciated. Thanks.

1
  • 1
    I assume your using windows? Have you considered using command prompt and shell commands. If you really want to use python you can wrap system commands using the os module in python. See here computerhope.com/movehlp.htm Commented Mar 18, 2015 at 1:37

1 Answer 1

5

I ended up looking up command-line approaches as suggested, and I put this together which worked well:

# maps local network drive to SharePoint directory (any open drive works)
os.system('net use r: {}'.format(sharepoint_url))

# uploads updated local file to SharePoint directory
os.system('copy {} r:\{}'.format(output_file_path, output_file_name))

# disconnects mapped network drive
os.system('net use r: /delete')

Hope this helps someone down the line.

Sign up to request clarification or add additional context in comments.

2 Comments

In my case, I did not need to put in username/password arguments as I am always on the network, but others might need to. Fairly straightforward, command-line gives the syntax for that case.
It does not work for me. What should be the format of the url?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.