#!/usr/bin/env python3 """ # Script ob-chore ## Metadata **Kind**: #obsidian/ob-script **Language**: #python **Parent**:: [[Obsidian Chore Scripts]], [[Executable Markdown File]] ## Synopsis Run all #obsidian/ob-script's. ## Script ```python # """ import os from pathlib import Path import subprocess import re def count_matching_lines(file_path, pattern): count = 0 with open(file_path, "r") as file: for line in file: if re.search(pattern, line): count += 1 return count script_directory = Path(__file__).resolve().parent os.chdir(script_directory.parent.parent) IGNORED = { "ob-chore.md": True, "ob-colors.md": True, "ob-file-tasks.md": True, "ob-file-ideas.md": True, "ob-file-picks.md": True, "ob-lychee.md": False, } for filename in os.listdir(script_directory): # Check if the file starts with "ob-" and has a ".py" extension if filename.startswith("ob-") and filename.endswith(".md"): if IGNORED.get(filename, False): continue elif filename == "ob-create-diaries.md": print("==> ob-file-tasks.md") subprocess.run(["python", script_directory / "ob-file-tasks.md"]) print("==> ob-file-picks.md") subprocess.run(["python", script_directory / "ob-file-picks.md"]) print("==> ob-file-ideas.md") subprocess.run(["python", script_directory / "ob-file-ideas.md"]) print(f"==> {filename}") subprocess.run(["python", script_directory / filename]) elif filename == "ob-rand.md": occurrences = count_matching_lines("shore/boards/,rand.md", r"^- \[ \] ") if occurrences > 20: print(f"==> {filename} (skipped)") else: print(f"==> {filename}") subprocess.run(["python", script_directory / filename]) else: print(f"==> {filename}") subprocess.run(["python", script_directory / filename]) """ # vim: ft=python ``` """