Issues with batch conversion / export

• Jan 3, 2022 - 16:27

Hi,

I'm using Musescore 3.6.2 on Windows 10 and I've installed the Batch Convert Plugin in order to automize the conversion of hundreds of .mscz files into .musicxml and .png files. The plugin seems to be installed properly since the conversion is working.

However I encounter two problems with the plugin:
1) Corrupted files bring up a window with the message that the current file is corrupted and you have to choose either to ignore or to abort the file. This arises when the plugin tries to open the .mscz file via .readScore().
2) For several files (not all) a window pops up where Musescore wants you to save changes. This occurs when the plugin tries closing the opened .mscz file again via calling .closeScore().
I cannot figure out for which .mscz files this happens and for which not. The only thing I could figure out is that the function call .readScore() already seems to decide whether there need to be changes saved or not. Also if nothing in the score was changed.
I also took a look into the Documentation for Musescore 3, but also changing the bool parameter 'noninteractive' of .readScore() does not change anything.

As far as I understood a similar problem already occured in Musescore 2 (see https://musescore.org/en/node/55616#comment-257376) but now in Musescore 3 there seems to be the same problem.

Is there any way to workaround these two issues? Permanently windows popping up some kind of destroy the functionality of a batch conversion, especially when it comes to several hundreds of files.

Is there maybe a way such that the plugin is able to save changes in the current score or any other way to workaround the two issues?

(I've downloaded the plugin for Musescore 3.x from https://musescore.org/de/project/batch-convert)

Best wishes


Comments

Here's what that noninteractive is supposed to do:

//---------------------------------------------------------
//   readScore
///   Reads the score from a file and opens it in a new tab
///   \param name Path to the file to be opened.
///   \param noninteractive Can be used to avoid a "save
///   changes" dialog on closing a score that is either
///   imported or was created with an older version of
///   MuseScore.
//---------------------------------------------------------
 
      Q_INVOKABLE Ms::PluginAPI::Score* readScore(const QString& name, bool noninteractive = false);

So setting it to true should have an effect on your 2nd issue, and is why the plugin does exactly that:

            // read file
            var thisScore = readScore(fileFullPath, true)

A score gets marked as being modified (and as such in need to gatting saved) if it gets imported from a previous major version, in the case of MuseScore 3.6 also of the score is from an older 3.x version.
Are you saing it doesn't work? Maybe it is an issue with pre-3.6 score in MMuseScire 3.6, maybe the migration there is working differently from like importing 2.x or 1.x scores?

For the corruption issue that won't help and I don't think there's a possible cure.

In reply to by Jojo-Schmitz

Thank you for the quick answer.

This is probably the reason for some scores being marked as modified by my Musescore version. However setting the parameter to 'true' does not change anything. They are still marked as modified and the 'save changes window' pops up.

Since I'm new to Musescore I do not know whether or how it's possible to migrate older file versions to the current one. Is that somehow possible? Maybe even such that I could automize that via code since I have to do that for hundreds of files.

Or does a function exist that simply can save the current score? That could be easily added to the .qml file of the Batch Convert plugin and would then also avoid the problem.

In reply to by finesse129

As per #56216: Can't save a score from within a plugin with saveAs()

Edit: no, with writeScore() (which does use saveAs().

//   writeScore
///   Writes a score to a file.
///   \param s The score which should be saved.
///   \param name Path where to save the score, with or
///   without the filename extension (the extension is
///   determined by \p ext parameter).
///   \param ext Filename extension \b without the dot,
///   e.g. \p "mscz" or \p "pdf". Determines the file
///   format to be used.
//---------------------------------------------------------
 
      Q_INVOKABLE bool writeScore(Ms::PluginAPI::Score* s, const QString& name, const QString& ext);

In reply to by Jojo-Schmitz

I added writeScore() (see line 536 in the screenshot) which should overwrite thisScore which is opened in line 528 via readScore(). I also added another writeScore() right before the closeScore() (line 578) just to make sure that thisScore is overwritten and saved.

However, when the programm reaches closeScore() (line 579), I still get the 'save changes pop up window'. So this does not seem to save the score thisScore (and thus save my problem) or did I do something wrong in the implementation of writeScore()?

Attachment Size
batchConvert_screenshot.png 271.06 KB

Do you still have an unanswered question? Please log in first to post your question.