Skip to content

Instantly share code, notes, and snippets.

View garethdigby's full-sized avatar

Gareth Digby garethdigby

View GitHub Profile
@garethdigby
garethdigby / backup-to-git.py
Created January 15, 2018 00:24 — forked from paultopia/backup-to-git.py
quick python script to run to backup on an unversioned directory (like dropbox, icloud, where git would break) of files with given extension to git repo. Just modify the first three lines, and stick the target directory in a private github repo or something
#!/usr/bin/env python
target_dir = "FULL_PATH_TO_YOUR_TARGET_DIRECTORY_WITH_GIT_REPO" # example: /Users/you/github/backup/
source_dir = "FULL_PATH_TO_YOUR_TARGET_DIRECTORY_WITH_NO_GIT" # example: /Users/you/Dropbox/ImportantDocuments/
extensions = ["txt", "md"] # example list of extensions to copy, change to suit you.
import glob, shutil, subprocess, os
source_wildcards = [source_dir + "*." + x for x in extensions]
source_filenames = []