How to use the "conversion job" command-line option
I figured out how to use the command-line option for converting a bunch of files all at once. The command-line is:
mscore [options] [filename] (Mac and Linux)
MuseScore.exe [options] [filename] (Windows)
the "conversion job" option is -j or --job and it takes a json formatted file. So, the command line on the Mac is:
/Applications/MuseScore\ 2.app/Contents//MacOS/mscore -j conversion-job.json
Here's an example of the conversion-job.json file to convert from "mscz" to "mscx" (useful for searching through a bunch of files for text entries since the mscx format contains uncompressed text):
[
{ "in":"Bagopolier_Freylekhs.mscz","out":"../xmlScores/Bagopolier_Freylekhs.mscx"},
{ "in":"Beckerman_No.14.mscz","out":"../xmlScores/Beckerman_No.14.mscx"},
{ "in":"Beckerman_No.5.mscz","out":"../xmlScores/Beckerman_No.5.mscx"},
{ "in":"Beckerman_No.6.mscz","out":"../xmlScores/Beckerman_No.6.mscx"},
{ "in":"Beckerman_No._1.mscz","out":"../xmlScores/Beckerman_No._1.mscx"}
]
Note that the last entry does not have a comma. The output file extension determines what type of conversion musescore will produce. You can create many different formats using this technique.
Enjoy!
Comments
This would make up for a nice How To ;-)
Which we then could and should add as a link to the handbook
In reply to This would make a nice How… by Jojo-Schmitz
Done: https://musescore.org/en/node/276951
In reply to Done: https://musescore.org… by howardU
Thanks! I've added the link to the handbook
In case you were not aware: there's also a plugin for this Batch Convert
In reply to This would make a nice How… by Jojo-Schmitz
Done: https://musescore.org/en/handbook/3/command-line-options#Run_a_batch_jo…
(the corresponding code PR has been merged, still waiting for the manpage PR to be merged)
How does this work with parts?
In reply to How does this work with… by mirabilos
Hmm.
With
-P -j jobname.jsn
parts are appended to the master PDF file, simply as new pages. This is suboptimal, but at least they’re there.In reply to Hmm. With -P -j jobname.jsn… by mirabilos
Oh fuuuuuck, -P also appends parts for scores that have no parts. Autogenerated parts, one for each instrument.
This just cost me over an hour of my night to make my scripts adapt. I now unzip the
META-INF/container.xml
, look for the.mscx
name in the.mscz
file, extract that, grep for the «lid» tag’s presence (the “best” way I could find to easily identify a score with parts, nested «Score» tags are more proper but much harder to do in shell), collect them in multiple distinct JSON files (one for mscore2 without parts, one for mscore2 with parts, one for mscore3 without… you get the idea) and run multiple-j
and-P -j
invocations.In reply to Oh fuuuuuck, -P also appends… by mirabilos
If you're not an American you might not understand, but the second word should really be changed in your post.
In reply to If you're not an American… by mike320
American? Isn’t that something to eat? I don’t understand.
In reply to How does this work with… by mirabilos
Looking at the source code, there’s no programmatical way at all to get at the individual parts from the command line:
MuseScore::exportParts()
inmscore/file.cpp
is a GUI operation (not split into GUI and under-the-hood parts, and with some ugly duplication even) and not exposed via the CLI.The PDF also does not include any indication where a part begins (e.g. as metadata). Its title does reflect that it’s “partitura and excerpts”, but that’s all.
Looking at the source code, there’s more.
You already found out that it must be a JSONArray of JSONObjects. All of the JSONObjects must have an
in
key, and they may have anout
key. What’s new, they also may have aplugin
key. The values of these keys are stringified (so probably should be JSONStrings in the first place) and passed to the conversion function.Either
out
orplugin
must be given, although both may be given. (The-S
option may also be used in conjunction with this and is honoured.) If a plugin is given, it’s loaded (by filename, must end with.qml
, is relative to the global or per-user plugin directory) and triggered (run). Then, ifout
is given, the score is saved/exported.Known file types for saving/exporting are:
-P
)-P
)