# Save .mrk.json files from .mrb without opening each .mrb

**URL:** <https://discourse.slicer.org/t/save-mrk-json-files-from-mrb-without-opening-each-mrb/26539>\
**Category:** Support\
**Created:** [December 1, 2022, 3:42pm UTC](https://discourse.slicer.org/t/save-mrk-json-files-from-mrb-without-opening-each-mrb/26539 "2022-12-01T15:42:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Masteling](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/masteling/32/13587_2.png) [@Masteling](https://discourse.slicer.org/u/Masteling)\
**Post date:** [December 1, 2022, 3:42pm UTC](https://discourse.slicer.org/t/save-mrk-json-files-from-mrb-without-opening-each-mrb/26539/1 "2022-12-01T15:42:54Z")

</div>

Is there a way to save all mrk.json files in a .mrb bundle without opening each .mrb individually and selecting the .mrk.json files individually in the save window?

Context:  
For each subject I have a .mrb file that contains the relevant .mrk.json files. I use Spyder ([https://www.spyder-ide.org/](https://www.spyder-ide.org/)) for data analysis of the contents of the .mrk.json files.

Currently, I open each .mrb file and select the .mrk.json files manually (about 20 files per subject) in the save window and save them into a folder. Is there a way to do this without needing to open each .mrb file individually? The project is quickly expanding and I would like to automate this step.

---

<div class="post-metadata">

**Author:** ![pieper](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/pieper/32/8_2.png) [@pieper](https://discourse.slicer.org/u/pieper)\
**Post date:** [December 1, 2022, 4:33pm UTC](https://discourse.slicer.org/t/save-mrk-json-files-from-mrb-without-opening-each-mrb/26539/2 "2022-12-01T16:33:02Z")

</div>

The `.mrb` file is just a `.zip`, so you can open it and extract the `.mrk.json` files pretty easily with a python script.

---

<div class="post-metadata">

**Author:** ![Masteling](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/masteling/32/13587_2.png) [@Masteling](https://discourse.slicer.org/u/Masteling)\
**Post date:** [December 1, 2022, 5:07pm UTC](https://discourse.slicer.org/t/save-mrk-json-files-from-mrb-without-opening-each-mrb/26539/3 "2022-12-01T17:07:28Z")

</div>

Thank you for the quick response. I got it working.

Here is my approach in case others have the same question:

```auto
using zipfile
using json

archive = zipfile.ZipFile(directory+mrb_name, 'r')
filenames = [x for x in archive.namelist() if '.mrk.json' in x]
f = archive.open(filenames[i])
data = json.load(f)

```
