Creating folders from a plugin

• Sep 5, 2022 - 22:01

Anyone knows how to create a folder with a plugin ?

Actually I was working on extending the Batch Convert plugin to export the files in a folder structure based on the score properties(*)

Creating folder is not possible by standard QML and javascript.

So I was wondering if there were other MuseScore objects able to do that.
* I was hoping that writeScore(...) would do this if the target folder was not existing but it doesn't :-( (could perhaps be an improvement request)
* I could call an external script with this tip start another program commandline but it isn't very portable.
* Any other idea ?

Thanks


(*): For example, organise all the exports by composer: create one sub-folder by composer and place all the exports of scores from that composer in this folder:
export structure.png


Comments

For now my solution is to work with a platform specific script and QProcess

import MuseScore 3.0
import QtQuick 2.9
MuseScore {
  anchors.fill: parent
  menuPath: "Plugins.mcveMkdir"
  requiresScore: false
  QProcess {
    id: proc
  }
  onRun:{
    console.log("------");
    console.log("OS : "+Qt.platform.os);
    proc.start("cmd /c mkdir \"d:\\misc\\temp\\foo bar8\""); // OK
    //proc.start("cmd /c mkdir \"d:/misc/temp/foo bar9\""); // OK
    var val = proc.waitForFinished(3000);
    if (val) console.log("stdout : "+proc.readAllStandardOutput())
      //else console.log("stderr : "+proc.readAllStandardError()) // not supported
      else console.log("something went wrong")
  }
}

Anyone could tell me how I should write cmd /c mkdir \"d:\\misc\\temp\\foo bar8\"to be valid under Linux, MacOS, ... (and other platforms supported by MuseScore) ?

In reply to by Jojo-Schmitz

Indeed. That's why I've made a separated branch on my repo.
To be decided later on if it is merged or not into the main branch of the plugin.
It could also be a temporary solution while waiting for FileIO or .writeScore to better handle these situations (I will fill a Feature Request for both).

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