-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDropboxPath.py
More file actions
34 lines (26 loc) · 1 KB
/
Copy pathDropboxPath.py
File metadata and controls
34 lines (26 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import sys
import json
from pathlib import Path
# Determine local Dropbox path
# Operating system specific paths
def dropboxPath(LOC=None):
if sys.platform == "win32":
info_path = Path(os.getenv("APPDATA")) / "Dropbox" / "info.json"
if not info_path.exists():
info_path = Path(os.getenv("LOCALAPPDATA")) / "Dropbox" / "info.json"
else:
info_path = Path.home() / ".dropbox" / "info.json"
# Read the info.json file to get the local Dropbox path
with open(info_path) as f:
data = json.load(f)
# Check if the user has a business or personal Dropbox account
try:
local_dropbox_path = Path(data["business"]["path"])
except:
local_dropbox_path = Path(data["personal"]["path"])
# Append the relative path to the local Dropbox path
if LOC is not None:
local_dropbox_path /= LOC.lstrip("/\\")
return local_dropbox_path
# Now you can use local relative paths within this directory