mscz file format

• Nov 12, 2022 - 01:46

I am trying to make changes in a number of mscz file programatically. I am using a Macbook Pro with Monterey 12.6 and Musescore 3.6.2.
I can uncompress a mscz file (after changing the extension to zip) using the standard zip procedure. This produces a folder including a number of things including an mscx file that can be edited and opened directly in Musescore. However if I then zip the folder, even without touching any files in it, I don't recover the original mscz file - the zipped file is larger and won't open in Musescore.
Does Musescore use a non-standard compression procedure? If so is there any way to access the procedure?
Alternatively, can someone explain what is going on please?
Thanks for your help.


In reply to by Mr Fox

Thanks Mr Fox. I have read as much of the documentation as I can find. However as I am rapidly discovering, "ZIP-compressed" can mean many things, and in particular possibly different things in a mac and a windows environment.
I can take a .mscz file and uncompress it using mac's standard "zip" function and I get a folder with meaningful files. However if I then zip the same folder again, using mac's standard zip function, I don't get the original file. I am assuming this is because the zip algorithm used to create .mscz files is different from mac's standard function. I was wanting to know if anyone has any information on exactly what compression algorithm is used to create .mscz files. Or else whether I have the wrong end of the stick entirely, which is quite possible :)

> However if I then zip the folder, even without touching any files in it, I don't recover the original mscz file - the zipped file is larger and won't open in Musescore.
I have never tried this way.
But why not just open your modified *.mscx file in musescore and then save it as *.mscz?

In reply to by HildeK

Thanks HildeK. I am intending to use this process on a number of files (18 initially but more later) and I'd rather not open each one individually and save - I find the more manual processes there are, the more opportunity for error. However if I can't find a way to do this programatically that is what I will need to do.

In reply to by rob_bullen

I did some investigations.
If I unzip a musescore file 'song.mscz' a directory 'song' is created and the contents is:
- song.mscx
- dir Thumbnails
- dir META-INF

Now, if I zip it again, then the structure of the new zipped file is:
- a directory song with the content:
- song.mscx
- dir Thumbnails
- dir META-INF

That means: my zip tool (7-zip) creates one more directory! This structure musescore does not understand.
Try it: unzip a mscz, zip the created directory again and the open it with the zip tool and compare.

In reply to by HildeK

There are clearly many versions of "ZIP". If I use "Archive Utility" which is the default on my mac, after unzipping I get a directory structure that is exactly as you say. If I then zip the directory I get a zipped file that is larger than the original. But if I unzip this file again I get exactly the same directory structure (no additional directory). So "Archive Utility" retains the contents of the original file but still adds something to the zip that is not added by whatever creates the .mscz files. I'm exploring other archiving tools to see if there is one that will regenerate the .mscz file.
Thanks for your interest and help.

In reply to by rob_bullen

Of course, the different tools for zipping do not produce the identical file and file size. I think the slightly different file size is not the problem as long as the content fits.
I tried it with 7-zip (on Windows) and if I then have the correct structure of the zip content (without the actual content being in an additional directory), then it works with Musescore.
Unfortunately I do not know the zipping tool from MAC. Maybe there is 7-zip also for the MAC.

In reply to by HildeK

Unfortunately there is no 7-zip for mac. If this is the only tool that will replicate the exact format of .mscz files then I may be snookered. (I could run a program in Windows using Parallels on the mac, but that would be MUCH too complicated.) I am hoping someone will know the exact tool or algorithm used to create .mscz files so I can see if it can be reproduced. Thanks again.

In reply to by rob_bullen

Yes, try this tool.
My suggestion for this (version 3.6.2, on Windows, may be slightly different on MAC OS):
- Extract a musescore file. You will get the mscx and the two directories META-INF and Thumbnails. 7-zip can open the *.mscz file directly.
- Modify the mscx file and save it.
- Then mark these three parts together and use the context menu entry 7-zip: add to
- Rename the result to filename.mscz.

In my Windows environment this is how it works with Musescore.

In reply to by HildeK

I can't make it work, I'm afraid. My operations are:
- take a .mscz file, extract to a folder using 7zip from a command (x source -oextractedfolder). This gives a file structure in the extracted folder as you describe - just two folders and the mscx file.
- I then zip the destination folder using 7zip add (a newzipfile extractedfolder)

The file newzipfile isn't identical to the original mscz file and it can't be opened in Musescore. However if I extract newzipfile, the contents of the extracted folder are identical to the contents of the original extracted folder.

I think this is getting too hard - possibly it's about differences between Windows and Mac environments or even versions of the zip software. I even tried opening Musescore programatically to see if I could tell it to open the mscx and save as mscz. If that's possible it's not simple.

I think I'll just do it manually for each file. Thanks for your help, and possibly this might inspire someone to find a solution.

In reply to by rob_bullen

I don't know if possible via the 7-zip command line, but have you tried replacing the mscx in the existing archive rather than creating a new archive? At least on windows that's how I (manually) edit scores: Open up in the 7-zip gui, extract just the mscx, then drag the modified back in and answer "yes" to the replacement question.

AFAIK MuseScore uses the default Qt::Zip to zip/unzip, so it should be about as default and standard as a ZIP can get.

Another approach is indeed to use MuseScore to convert mscx back to mscz, either via the Batch Convert Plugin or According to the command line options
mscore -o "MyFile.mscz" "MyFile.mscx"

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