import os
import subprocess
root_dir = "/home/nwpwr/Dropbox/Notes/roam/" # TODO Change this
ignore_folder = ".stversions"
for subdir, dirs, files in os.walk(root_dir):
# Ignore the .stversions folder
dirs[:] = [d for d in dirs if d != ignore_folder]
for file in files:
if file.endswith(".org") and "conflict" in file:
conflict_file = os.path.join(subdir, file)
original_file_name = file.split(".sync-conflict")[0] + ".org"
original_file_path = os.path.join(subdir, original_file_name)
print(f"There is a conflict: {conflict_file}")
if os.path.exists(original_file_path):
user_input = input(f"Do you want to compare {original_file_name} with {file}? (y/n): ")
if user_input.lower() == 'y':
# Running the ediff command using emacsclient directly
subprocess.run([
"emacsclient",
"-c",
"-n",
"--eval",
f"(ediff \"{original_file_path}\" \"{conflict_file}\")"
])