This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Iteratively loop through all files in DIR and add-commit-push them to REPO. | |
This script should sit in your obsidian vault. | |
""" | |
from pathlib import Path | |
from git import Repo | |
import os | |
DIR = '/Users/eugene/obsidian-vault/assets' | |
REPO = Repo('.') | |
for i, path in enumerate(Path(DIR).iterdir()): | |
file_size = int(os.stat(path).st_size / 1024) | |
print(f'file {i}: {str(path).split("/")[-1]} ({file_size} kb)') | |
if file_size < 1024: | |
commit_msg = f'Add {str(path).split("/")[-1]}' | |
REPO.index.add(str(path)) # Add | |
REPO.index.commit(commit_msg) # Commit | |
origin = REPO.remote('origin') | |
origin.push() # Push | |
else: | |
print(f'Skipping file {i}: {str(path).split("/")[-1]} ({file_size} kb)') | |
f = open("skipped-files.txt", "a") | |
f.write(f'{str(path).split("/")[-1]}\n') | |
f.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment