# Export Masters to Subfolders

**URL:** <https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281>\
**Category:** Scripting\
**Created:** [December 8, 2024, 11:34am UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281 "2024-12-08T11:34:11Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_w](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/david_w/32/28940_2.png) [@David\_w](https://forum.glyphsapp.com/u/David_w)\
**Post date:** [December 8, 2024, 11:34am UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/1 "2024-12-08T11:34:11Z")

</div>

I was looking for a script that could export my instances into separate folders. Let’s assume I have a Thin, Regular, and Bold instance. And I want to export them to a structure like this:

`FontName/Weight/*otf,*ttf,*woff2 …`

That would mean I get 3 sub-folders inside the FontName folder with the respective font-files.

Right now I have to select each and every instance and font-file by hand and move them to those sub-folders (i need those to provide the different weights as downloads). I wasn’t able to find a script that would do that for me.

I’m working with glyphs 3 in a \*.glyphs-file with 6 masters and about 20 instances defined in export.

Thanks a lot in advance for looking into it.

---

<div class="post-metadata">

**Author:** ![alexs](https://forum.glyphsapp.com/letter_avatar_proxy/v4/letter/a/2acd7d/32.png) [@alexs](https://forum.glyphsapp.com/u/alexs)\
**Post date:** [December 8, 2024, 1:08pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/2 "2024-12-08T13:08:45Z")

</div>

Export all files into one folder, change the `path` below to that folder, and it should do the trick:

```auto
import os, shutil
path = '/Users/UserName/Desktop/Fonts'

list_ = os.listdir(path)
for file_ in list_:
	name, ext = os.path.splitext(file_)
	if ext.lower() in ['.otf', '.ttf', '.woff', '.woff2', '.eot']:
		folder = path + '/' + name
		
		# create a folder
		if os.path.exists(folder) is False:
			os.makedirs(folder)
		
		# move the file to the folder
		shutil.move(path + '/' + file_, folder + '/' + file_)

```

---

<div class="post-metadata">

**Author:** ![SCarewe](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/scarewe/32/18952_2.png) [@SCarewe](https://forum.glyphsapp.com/u/SCarewe)\
**Post date:** [December 8, 2024, 1:31pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/3 "2024-12-08T13:31:08Z")

</div>

Find the eweracs scripts in the plugin manager, they contain a script “Batch Export” which exports your instances into neat folders (ttf, otf, webfonts, etc)

---

<div class="post-metadata">

**Author:** ![GeorgSeifert](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/georgseifert/32/259_2.png) [@GeorgSeifert](https://forum.glyphsapp.com/u/GeorgSeifert)\
**Post date:** [December 8, 2024, 1:32pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/4 "2024-12-08T13:32:51Z")

</div>

No script required:  
Add a custom parameter

```auto
"Export Folder" = "FontName/{{{weightClassUI}}}/{{{format}}}/"

```

in the font setting. If you need more control add one per instance.

---

<div class="post-metadata">

**Author:** ![SCarewe](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/scarewe/32/18952_2.png) [@SCarewe](https://forum.glyphsapp.com/u/SCarewe)\
**Post date:** [December 8, 2024, 1:34pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/5 "2024-12-08T13:34:58Z")

</div>

I didn’t know about these tokens, that’s very cool. Where are they documented in the handbook?

---

<div class="post-metadata">

**Author:** ![alexs](https://forum.glyphsapp.com/letter_avatar_proxy/v4/letter/a/2acd7d/32.png) [@alexs](https://forum.glyphsapp.com/u/alexs)\
**Post date:** [December 8, 2024, 3:22pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/6 "2024-12-08T15:22:09Z")

</div>

> [@SCarewe](#):
>
> script “Batch Export”

I guess there’s no EOT anymore:

```auto
File "BatchExport.py", line 94, in __init__
    value=EOT in self.selected_formats["Web"]["Containers"])
          ^^^
NameError: name 'EOT' is not defined

```

---

<div class="post-metadata">

**Author:** ![SCarewe](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/scarewe/32/18952_2.png) [@SCarewe](https://forum.glyphsapp.com/u/SCarewe)\
**Post date:** [December 8, 2024, 3:26pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/7 "2024-12-08T15:26:29Z")

</div>

Makes sense. I haven’t updated the script in years. I have since made my own export plugin that replicates this script’s behaviour, with a lot more export options.

---

<div class="post-metadata">

**Author:** ![David\_w](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/david_w/32/28940_2.png) [@David\_w](https://forum.glyphsapp.com/u/David_w)\
**Post date:** [December 20, 2024, 11:36am UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/8 "2024-12-20T11:36:10Z")

</div>

> [@GeorgSeifert](#):
>
> `{{{weightClassUI}}}`

This is great and sorry for not checking in for so long after I initially asked.

I tried copying `{{{weightClassUI}}}` but it exports it as a literal folder not as a variable. Not sure if I got this wrong. The other solution would probably be, to create an “Export Folder” for each instance.

---

<div class="post-metadata">

**Author:** ![GeorgSeifert](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/georgseifert/32/259_2.png) [@GeorgSeifert](https://forum.glyphsapp.com/u/GeorgSeifert)\
**Post date:** [December 20, 2024, 4:23pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/9 "2024-12-20T16:23:54Z")

</div>

What version of Glyphs do you have? You might need to get the cutting edge version to get it to work.

---

<div class="post-metadata">

**Author:** ![David\_w](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/david_w/32/28940_2.png) [@David\_w](https://forum.glyphsapp.com/u/David_w)\
**Post date:** [December 21, 2024, 12:28pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/10 "2024-12-21T12:28:12Z")

</div>

> [@David\_w](#):
>
> `{{{weightClassUI}}}`

I have version 3.2.3 (3260) installed.

 ![Bildschirmfoto 2024-12-21 um 13.26.00](https://forum.glyphsapp.com/uploads/default/original/3X/2/4/24016169572e614ee9271d4ff1e2110bb8f7ea92.png)

This is how I have set it up under `Font Info/Font`. I select the font name folder by hand, when exporting. Do I need to activate something else?

---

<div class="post-metadata">

**Author:** ![SCarewe](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/scarewe/32/18952_2.png) [@SCarewe](https://forum.glyphsapp.com/u/SCarewe)\
**Post date:** [December 21, 2024, 12:50pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/11 "2024-12-21T12:50:04Z")

</div>

Can you try on the latest beta? You can install it by checking the “show cutting edge versions” in your Updates preferences of Glyphs.

Don’t worry, you can revert to the older version or even have multiple versions installed alongside one another.

---

<div class="post-metadata">

**Author:** ![David\_w](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/david_w/32/28940_2.png) [@David\_w](https://forum.glyphsapp.com/u/David_w)\
**Post date:** [December 21, 2024, 3:49pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/12 "2024-12-21T15:49:38Z")

</div>

Think I should add this: Thank you all. You are always so quick to reply and are so well informed. Really thankful for all the help I found in this forum.

I updated to the cutting edge version. It works in part. `{{{weightClassUI}}}/{{{format}}}` Creates a folder for the first weight and exports all other weights to the same folder. Format works though. It creates a new folders for each font format. I wonder if I might need a different variable or if there is something else going on. Can I find the various possible variables somewhere?

---

<div class="post-metadata">

**Author:** ![SCarewe](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/scarewe/32/18952_2.png) [@SCarewe](https://forum.glyphsapp.com/u/SCarewe)\
**Post date:** [December 21, 2024, 4:00pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/13 "2024-12-21T16:00:48Z")

</div>

Just to check, have you set the weight class differently for each instance? Or are they all set to 400: Regular?

---

<div class="post-metadata">

**Author:** ![David\_w](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/david_w/32/28940_2.png) [@David\_w](https://forum.glyphsapp.com/u/David_w)\
**Post date:** [December 21, 2024, 9:39pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/14 "2024-12-21T21:39:53Z")

</div>

For the one I tested it with no. I checked with another one, where I set different weights. There it worked. Thanks for pointing that out.

Still, I have two axis in the large font—one for weight and one for serif/sans. I would need to write a different variable I guess. Is there some kind of list, so I could customize the variable? Ideally I would like to use “Style Name” as a variable.

---

<div class="post-metadata">

**Author:** ![GeorgSeifert](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/georgseifert/32/259_2.png) [@GeorgSeifert](https://forum.glyphsapp.com/u/GeorgSeifert)\
**Post date:** [December 21, 2024, 10:02pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/15 "2024-12-21T22:02:03Z")

</div>

You can use all kinds of things in those tokens. try: `{{{name}}}`.

---

<div class="post-metadata">

**Author:** ![David\_w](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/david_w/32/28940_2.png) [@David\_w](https://forum.glyphsapp.com/u/David_w)\
**Post date:** [December 23, 2024, 9:14am UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/16 "2024-12-23T09:14:20Z")

</div>

This works perfectly, and will make exporting and sorting so much easier in the future.  
To get the folder structure I needed I used `{{{familyName}}} {{{name}}}` to get “Fontname Exported Weight” as a result. Thanks a lot to everyone who helped. Have a nice holiday and a happy new year.

---

<div class="post-metadata">

**Author:** ![inzn](https://forum.glyphsapp.com/letter_avatar_proxy/v4/letter/i/e19adc/32.png) [@inzn](https://forum.glyphsapp.com/u/inzn)\
**Post date:** [January 12, 2026, 11:48am UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/17 "2026-01-12T11:48:22Z")

</div>

Hey Sebastian, the Batch Export script appears to be broken:  
`Traceback (most recent call last):`  
`File “BatchExport.py”, line 165`  
`ExportWindow()`  
`File “BatchExport.py”, line 94, in ` **`init`**  
`value=EOT in self.selected_formats[“Web”][“Containers”])`  
`^^^`  
`NameError: name ‘EOT’ is not defined`

---

<div class="post-metadata">

**Author:** ![SCarewe](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/scarewe/32/18952_2.png) [@SCarewe](https://forum.glyphsapp.com/u/SCarewe)\
**Post date:** [January 12, 2026, 12:31pm UTC](https://forum.glyphsapp.com/t/export-masters-to-subfolders/32281/18 "2026-01-12T12:31:55Z")

</div>

I don’t intend on developing that script further, since I’ve developed a much more powerful custom export plugin. I hope to release a “lite” version of it with reduced functionality (basically, only what the Batch Export plugin does) sometime in the coming months.
