From 355d4996dc32988aabe000fbfaa1a9bbdd9ec585 Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Sun, 26 Mar 2023 13:49:36 +0200 Subject: Add initial scripts --- mscz2pdfs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 mscz2pdfs (limited to 'mscz2pdfs') diff --git a/mscz2pdfs b/mscz2pdfs new file mode 100755 index 0000000..e037086 --- /dev/null +++ b/mscz2pdfs @@ -0,0 +1,36 @@ +#!/bin/bash + +# Converts a MuseScore file to PDFs, one for each part. +# USAGE: mscz2pdfs -s -o + +score= +output_dir='.' + +while getopts 's:o:' flag; do + case "${flag}" in + s) score=$OPTARG ;; + o) output_dir=$OPTARG ;; + *) error "Unexpected option ${flag}" ;; + esac +done + +if [ -z "$score" ]; then + echo "Provide score" +fi + +base_filename=${score%.mscz} +base_filename=${score##*/} +json=`mktemp "/tmp/tmp-XXXXXXX.json"` +echo "putting json in $json" + +musescore --score-parts-pdf "$score" > "$json" + +parts=`jq --raw-output '.parts[]' "$json"` + +i=0 +IFS=$'\n'; +for part in $parts; do + jq --raw-output ".partsBin[$i]" "$json" | base64 --decode > "$output_dir"/"$base_filename-$part.pdf" + i=$((i + 1)) +done +IFS=' ' -- cgit v1.2.3