Resolve a path inside your local OneDrive folder, cross-platform
pip install onedrivepath
To edit, install in editable mode instead and just modify the files in this repo directly:
pip install -e .
Installed via PyPI, so update to the latest published version with:
pip install --upgrade onedrivepath
Resolves a path inside your local OneDrive folder (Windows/macOS; best-effort on Linux via unofficial clients).
from OneDrivePath import onedrivePath
onedrivePath("/folder/I/Care/About/")
# 'C:/Users/.../OneDrive/folder/I/Care/About'
onedrivePath()
# 'C:/Users/.../OneDrive'If you have multiple OneDrive accounts (e.g. personal + work/school), pass account to
pick one. Matching is a case- and punctuation-insensitive substring check against the
local folder name, the same way on every platform:
onedrivePath(account="google")
# 'C:/Users/.../OneDrive - Google'
onedrivePath("Research/Data", account="google")
# 'C:/Users/.../OneDrive - Google/Research/Data'This matches whatever your OneDrive folder is actually named.
e.g. if your school's folder is OneDrive - Neuromob University:
onedrivePath(account="neuromob")
# 'C:/Users/.../OneDrive - Neuromob University'
onedrivePath("Coursework", account="neuromob")
# 'C:/Users/.../OneDrive - Neuromob University/Coursework'If you'll be using the same account for most calls, set it once with setAccount instead
of passing account every time. It validates immediately, so a bad name fails fast:
from OneDrivePath import onedrivePath, setAccount
setAccount("neuromob")
onedrivePath()
# 'C:/Users/.../OneDrive - Neuromob University'
onedrivePath("Coursework")
# 'C:/Users/.../OneDrive - Neuromob University/Coursework'
onedrivePath("Photos", account="google") # per-call account still overrides
# 'C:/Users/.../OneDrive - Google/Photos'