forked from srbcheema1/my_scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsync.py
More file actions
22 lines (13 loc) · 626 Bytes
/
sync.py
File metadata and controls
22 lines (13 loc) · 626 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/env python3
import os
from os.path import basename
import pyinotify
dirname = "/home/redrield/Documents/Classroom" # Change directory to what you want here
rcloneDriveName = "School Drive" # Change rclone drive to the one you've defined and you want to sync
watchManager = pyinotify.WatchManager()
mask = pyinotify.IN_DELETE | pyinotify.IN_MODIFY | pyinotify.IN_CREATE
watchManager.add_watch(dirname, rec=True, mask=mask)
def handler(ev):
os.system("""rclone sync {} "{}:/{}" """.format(dirname, rcloneDriveName, basename(dirname)))
notifier = pyinotify.Notifier(watchManager, handler)
notifier.loop()