Skip to main content

sharefetch

Download a SharePoint Online or OneDrive for Business folder tree to a local directory, resumably and with content-level verification.

PythonLicense: MIT

$ sharefetch "https://contoso.sharepoint.com/sites/Example/Shared Documents/Logs" --dest D:/archive
INFO sharefetch.cli To sign in, use a web browser to open the page https://login.microsoft.com/device and enter the code J7QK4RN2P to authenticate.
INFO sharefetch.cli signed in as user@contoso.com
INFO sharefetch.cli resolved to the Shared Documents library, folder 'Logs'
INFO sharefetch.cli enumeration complete: 15 file(s) in 0 folder(s), 11049892 byte(s)
INFO sharefetch.cli Logs/Q3 Summary.pdf: starting, 2939254 byte(s)
INFO sharefetch.cli Logs/Q3 Summary.pdf: complete, verification passed
INFO sharefetch.cli Logs/Change Register.xlsx: complete, verification passed
INFO sharefetch.cli run finished: 15 transferred, 0 already present, 0 skipped, 0 failed, 15 verified, 11049892 byte(s) transferred
INFO sharefetch.cli manifest: D:\archive\manifest.csv

Installation

$ pip install sharefetch

Python 3.10 or later. Windows is the target platform, because path handling and the token cache are Windows-specific.

From a clone:

$ git clone https://github.com/Indspl0it/sharefetch.git
$ cd sharefetch
$ pip install -e .

Two commands are installed, sharefetch for the terminal and sharefetch-gui for a window.

Usage

The folder URL from the browser address bar is the only argument.

$ sharefetch "https://contoso.sharepoint.com/sites/Example/Shared Documents/Logs"

A device code appears on the first run. Entering it at the verification page on any device starts the transfer. Later runs use the cached token and print no code.

Choose a destination and slow the transfer down:

$ sharefetch "<url>" --dest D:/archive --delay 2 --limit-rate 500

Report what a run would transfer, without transferring it:

$ sharefetch "<url>" --dry-run

Take part of a tree:

$ sharefetch "<url>" --include "*.pdf" --exclude "*/Archive/*" --max-depth 2

Re-check an existing download, without touching the network:

$ sharefetch "<url>" --dest D:/archive --verify-only

Run it again after an interruption. It reconciles against the disk, resumes the partial file from where it stopped, and skips everything already verified:

$ sharefetch "<url>" --dest D:/archive

Accepted URLs

Six forms are accepted, so whichever one the browser produced will work.

# library view with an id parameter
https://contoso.sharepoint.com/sites/Example/Shared%20Documents/Forms/AllItems.aspx?id=%2Fsites%2FExample%2FShared%20Documents%2FLogs

# direct folder path
https://contoso.sharepoint.com/sites/Example/Shared Documents/Logs

# teams-backed site
https://contoso.sharepoint.com/teams/Workgroup/Shared Documents/Notes

# subsite
https://contoso.sharepoint.com/sites/Parent/Child/Shared Documents/Reports

# personal OneDrive
https://contoso-my.sharepoint.com/personal/user_contoso_com/Documents/Archive

# sharing link, which needs --dest
https://contoso.sharepoint.com/:f:/s/Example/EhT7abc

Command line options

$ sharefetch <url> [options]

# where the tree lands
--dest DIR              # default: a folder named after the addressed folder
                        # required for a sharing link
--ignore-free-space     # skip the capacity check made before transferring

# network behaviour
--connections N         # 1 or 2, higher is rejected at parse time (default: 1)
--delay SECONDS         # pause between requests, 0.0 to 60.0, shared by
                        # every worker (default: 0.5)
--limit-rate KBPS       # transfer ceiling in KB/s (default: none)
--chunk-size KIB        # read size, 64 to 4096 (default: 256)

# what to transfer
--include GLOB          # only items matching the glob, repeatable
--exclude GLOB          # drop matching items, applied after --include
--max-depth N           # 0 is the addressed folder alone (default: unlimited)

# run mode
--resume                # continue from the state file (default)
--restart               # transfer every item again, removing nothing
--dry-run               # enumerate and report, writing no file content
--verify-only           # check the tree on disk, no sign-in and no network

# sign-in
--reauth                # ignore the cached token, force a new device code
--tenant ID             # tenant GUID or domain (default: organizations)
--client-id GUID        # application to sign in as
                        # (default: d3590ed6-52b3-4102-aeff-aad2292ab01c,
                        #  a Microsoft first-party public client)

# output
--log-file PATH         # write the log here as well as to stderr
                        # the device code is never written to it
--verbose               # log at DEBUG in place of INFO
--version               # print the version and exit

Exit codes: 0 every item complete and verified, 1 finished with failed or skipped items, 2 fatal during setup, 130 interrupted.

Licence

MIT. See LICENSE.

Metadata

Release files for sharefetch 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sharefetch 1.1.0
File Size Uploaded
sharefetch-1.1.0.tar.gz 182.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sharefetch 1.1.0
File Interpreter ABI Platform
sharefetch-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 295.0 kB

Release files / sharefetch-1.1.0.tar.gz

Download URL sharefetch-1.1.0.tar.gz
Size 182.4 kB
Tags Source
SHA-256 checksum
How to use checksums
d2f33859260fc28858ee8a1ec0297a5b1c7fbef32ccc284b5266a88c80a5aac5
BLAKE2b-256 checksum
How to use checksums
d5085f38f4012cb2e548c045289a5fb9e66f5e8b7a27983dfcf269c4cf2b455e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / sharefetch-1.1.0-py3-none-any.whl

Download URL sharefetch-1.1.0-py3-none-any.whl
Size 112.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6a428057c5573a0a3b0be7665b3f8c3adb6016137c05178cf511458aa23c5c67
BLAKE2b-256 checksum
How to use checksums
dc84df29cea73fa6b4e62c81168d94253c6fba60c130556af8377da2f0db3abb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page