#
Uploading and downloading contact to Sharepoint or Onedrive
tl,dr: Don't write your own script - just use rclone, available from: https://rclone.org/
rclone:
- is FOSS
- supports numerous cloud services.
- will work cross-platform with ease (pick your OS)
- allows you to upload, download and sync
- supports maintaining directory paths
#
Quick steps
This is a good visual guide for setup: Connecting to OneDrive with RClone - Murray's Blog
#
Copy (upload) files
A quick summary of the steps:
- Change directory to where rclone.exe is located, and run:
rclone config
- Select the option to make a new remote
- Create the config, by:
- Giving it a name,
- Selecting correct storage option (38 for OneDrive/SharePoint at time of writing)
- Accepting defaults for client_id, client_secret
- Select correct region for your tenant
- Accept defaults for tenant
- Do not edit advanced config
- Use the web browser to automatically authenticate with your remote, and complete the authentication and permission steps.
- Select the correct type of connection for what you are setting up (1 for OneDrive Personal or Business, etc). Options will be available to search for a OneDrive driveid or SharePoint site if needed.
- Select the drive you want to use (always select the one named OneDrive (business))
- Enter y, or press enter to save config
- Enter y, or press enter to keep the remote
- Enter q to quit
- Test the config by connecting to your new share, with this command:
.\rclone.exe ls RClone-Share-Name:"/path/to/destination/folder name/"
- Start uploading your content:
.\rclone.exe copy "E:\path\to\origin\folder name" RClone-Share-Name:"/path/to/destination/folder name/" -P --metadata --check-first --inplace -i -v
Command breakdown:
Other command switches can be found at: https://rclone.org/commands/rclone_copy/#copy-options