diff options
author | Marcin Chrzanowski <m@m-chrzan.xyz> | 2023-03-26 13:49:36 +0200 |
---|---|---|
committer | Marcin Chrzanowski <m@m-chrzan.xyz> | 2023-03-26 13:49:36 +0200 |
commit | 355d4996dc32988aabe000fbfaa1a9bbdd9ec585 (patch) | |
tree | f4af7671f8ed4fd9138d5fe5a723b64046de456f /mscz2pdfs | |
parent | 2a5b14312110abee3a70a2f59a8deacd6929031a (diff) |
Add initial scripts
Diffstat (limited to 'mscz2pdfs')
-rwxr-xr-x | mscz2pdfs | 36 |
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=' ' |