Add utility script

This commit is contained in:
Louis Thurman 2023-03-06 20:46:19 +00:00
parent d6cf261bfa
commit e327aeaca9
1 changed files with 25 additions and 0 deletions

25
render_and_play.py Normal file
View File

@ -0,0 +1,25 @@
import pathlib
import re
import subprocess
import sys
win_root = pathlib.Path(r"C:\Users\louis\GitKraken\dottes")
lin_root = pathlib.Path("~/dottes")
try:
win_abc_file_path = pathlib.Path(sys.argv[1])
except IndexError:
win_abc_file_path = pathlib.Path(input())
if not str(win_abc_file_path).lower().endswith(".abc"):
input("Doesn't look like an abc file.")
exit(1)
lin_abc_file_path = lin_root / win_abc_file_path.relative_to(win_root)
out_file_name = lin_abc_file_path.name.rsplit(".", 1)[0] + ".mid"
output_path = lin_abc_file_path.parent / out_file_name
command = f"abc2midi {lin_abc_file_path.as_posix()} -o {output_path.as_posix()}"
print("Command:", command)
r = subprocess.run([r"wsl"], input=command.encode())