m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/mscz2pdfs
diff options
context:
space:
mode:
Diffstat (limited to 'mscz2pdfs')
-rwxr-xr-xmscz2pdfs36
1 files changed, 36 insertions, 0 deletions
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 <score file> -o <output directory>
+
+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=' '