Skip to content

Instantly share code, notes, and snippets.

@Redrield

Redrield/sync.py Secret

Created October 25, 2017 17:19
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Redrield/81dd7c0cebd5760c65d1127495e487f8 to your computer and use it in GitHub Desktop.
Save Redrield/81dd7c0cebd5760c65d1127495e487f8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import os
from os.path import basename
import pyinotify
dirname = "/home/redrield/Documents/Classroom" # Change your dirname to whatever
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 {} "School Drive:/{}" """.format(dirname, basename(dirname))) # Change School Drive to the name of your drive
notifier = pyinotify.Notifier(watchManager, handler)
notifier.loop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment