# Batch export

**URL:** <https://forum.glyphsapp.com/t/batch-export/1383>\
**Category:** Scripting\
**Created:** [March 26, 2014, 12:18pm UTC](https://forum.glyphsapp.com/t/batch-export/1383 "2014-03-26T12:18:25Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mark/32/20784_2.png) [@Mark](https://forum.glyphsapp.com/u/Mark)\
**Post date:** [March 26, 2014, 12:18pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/1 "2014-03-26T12:18:25Z")

</div>

is there a way to export all open fonts to otf?

i tried a bit with the robofab way, but it doesn’t work.

---

<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:** [March 26, 2014, 12:50pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/2 "2014-03-26T12:50:28Z")

</div>

A script like this should do the trick:

Exporter = NSClassFromString(“GlyphsFileFormatOTF”).alloc().init()  
for f in Glyphs.fonts:  
…print f  
…Result = Exporter.writeFont\_error\_(f, None)  
…print “Result:”, Result

---

<div class="post-metadata">

**Author:** ![Mark](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mark/32/20784_2.png) [@Mark](https://forum.glyphsapp.com/u/Mark)\
**Post date:** [March 26, 2014, 1:28pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/3 "2014-03-26T13:28:24Z")

</div>

thank you, georg.

this is btw something that could be better documented, i guess? no chance to get there without asking you explicitly for the code 🙂

---

<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:** [March 26, 2014, 2:10pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/4 "2014-03-26T14:10:47Z")

</div>

We are working on the documentation quite hard. But there is still a lot to do. We have to fine a way to make it better accessible.

---

<div class="post-metadata">

**Author:** ![Mark](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mark/32/20784_2.png) [@Mark](https://forum.glyphsapp.com/u/Mark)\
**Post date:** [March 26, 2014, 2:36pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/5 "2014-03-26T14:36:07Z")

</div>

i can imagine this. just wanted to point that out, as you asked for help on that. 🙂

also: is that a typo, or supposed to be that:

‘ojbcClass’

? (found in the ‘print dir(Glyphs)’)

---

<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:** [March 26, 2014, 5:53pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/6 "2014-03-26T17:53:34Z")

</div>

A lot if the stuff you see in the dir() output comes from the pyObjC (hint) bridge.

---

<div class="post-metadata">

**Author:** ![Mark](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mark/32/20784_2.png) [@Mark](https://forum.glyphsapp.com/u/Mark)\
**Post date:** [March 26, 2014, 6:17pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/7 "2014-03-26T18:17:45Z")

</div>

i meant, that i thought it could be a miss-spelling?

_objcClass_ instead of _ojbcClass_

---

<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:** [March 26, 2014, 10:05pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/8 "2014-03-26T22:05:25Z")

</div>

You are right. This comes from a library I use for something completely unrelated. Interesting find.

---

<div class="post-metadata">

**Author:** ![Mark](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mark/32/20784_2.png) [@Mark](https://forum.glyphsapp.com/u/Mark)\
**Post date:** [June 22, 2014, 6:59pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/9 "2014-06-22T18:59:45Z")

</div>

and is there a way to script the UFO export as well? For all open files, and the very best would be an option to keep the filename of the glyphs-file instead the family name (wanna generate versions as UFO)

---

<div class="post-metadata">

**Author:** ![Mark](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mark/32/20784_2.png) [@Mark](https://forum.glyphsapp.com/u/Mark)\
**Post date:** [June 22, 2014, 7:03pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/10 "2014-06-22T19:03:09Z")

</div>

i changed the script to GlyphsFileFormatUFO and get no errors, but the save dialog opens and ask me to name the file and where to put. so this is a) what i like to skip (or define in the script) and b) i don’t know if this creates a proper file?

---

<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:** [June 22, 2014, 7:56pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/11 "2014-06-22T19:56:50Z")

</div>

Something like should get you started:

Exporter = NSClassFromString(“GlyphsFileFormatUFO”).alloc().init()  
for f in Glyphs.fonts:  
…print f  
…Master = f.fontMasters()[0]  
…Exporter.setFontMaster\_(Master)  
…FilePath = f.parent.fileURL().path()  
…FilePath = FilePath.replace(".glyphs", “-”+Master.name+".ufo")  
…Result = Exporter.writeUfo\_toURL\_error\_(f, NSURL.fileURLWithPath\_(FilePath) , None)  
…print “Result:”, Result

---

<div class="post-metadata">

**Author:** ![Mark](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mark/32/20784_2.png) [@Mark](https://forum.glyphsapp.com/u/Mark)\
**Post date:** [June 22, 2014, 8:46pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/12 "2014-06-22T20:46:07Z")

</div>

wow, this works like a charm, thanks so much, will play around. the only thing is that it still exports only the lightes master, but you said already that you work on that (the general ufo export problem atm).

thank you, georg!

---

<div class="post-metadata">

**Author:** ![Mark](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mark/32/20784_2.png) [@Mark](https://forum.glyphsapp.com/u/Mark)\
**Post date:** [June 22, 2014, 8:58pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/13 "2014-06-22T20:58:39Z")

</div>

oh, i just realized that the first master is indexed in the script. works also with the second. nevermind, but thanks again 🙂

---

<div class="post-metadata">

**Author:** ![Mark](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mark/32/20784_2.png) [@Mark](https://forum.glyphsapp.com/u/Mark)\
**Post date:** [February 16, 2015, 9:26am UTC](https://forum.glyphsapp.com/t/batch-export/1383/14 "2015-02-16T09:26:39Z")

</div>

Now I think of deriving a script, that exports WOFF and WOFF2, along with the @font-face CSS code. The latter bit I already got ready. So, but is it possible to reuse the _NSClassFromString(“GlyphsFileFormatUFO”).alloc().init()_ in some way to call the Webfont exporter? Or in any other way?

Thanks in advance!

---

<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:** [February 16, 2015, 2:38pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/15 "2015-02-16T14:38:31Z")

</div>

The webfont export is not scriptable at the moment. I worked on this but I’m not finished.

---

<div class="post-metadata">

**Author:** ![Mark](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mark/32/20784_2.png) [@Mark](https://forum.glyphsapp.com/u/Mark)\
**Post date:** [February 16, 2015, 5:07pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/16 "2015-02-16T17:07:56Z")

</div>

i’ll be patient, thanks!

---

<div class="post-metadata">

**Author:** ![Mark](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mark/32/20784_2.png) [@Mark](https://forum.glyphsapp.com/u/Mark)\
**Post date:** [September 3, 2015, 9:02am UTC](https://forum.glyphsapp.com/t/batch-export/1383/17 "2015-09-03T09:02:04Z")

</div>

Undusting this for something maybe related: Is it possible to access the Generate Instances via scripting? I am not seeking the instance method from the documentation here, but rather the ability to actually get the files ready for saving, with all the color labels etc. Basically exactly as the File \> Generate Instances behaves.

BTW: is it on purpose, that a generated instance might end up with a different Master (weight) name than its original Instance (weight) name was? In particular I got a Font:  
2 Masters (Regular [91], Bold [149])  
2 Instances, same Names, same weight values, same weight declaration

When I generate the Instances, the new files end up like this:  
One got Bold in Master and its Instance like expected, _but the other one has now »Light« as its Master name_, while its Instance is still »Regular« etc.

I assume the weight value might cause this? Anyway I am not sure if this should happen.

---

<div class="post-metadata">

**Author:** ![mekkablue](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mekkablue/32/23_2.png) [@mekkablue](https://forum.glyphsapp.com/u/mekkablue)\
**Post date:** [September 3, 2015, 9:50am UTC](https://forum.glyphsapp.com/t/batch-export/1383/18 "2015-09-03T09:50:54Z")

</div>

[quote=“Mark, post:17, topic:1383”]  
BTW: is it on purpose, that a generated instance might end up with a different Master (weight) name than its original Instance (weight) name was?[/quote]

The one thing does not have much to do with the other. Does the Master name matter for what you want to do?

---

<div class="post-metadata">

**Author:** ![mekkablue](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mekkablue/32/23_2.png) [@mekkablue](https://forum.glyphsapp.com/u/mekkablue)\
**Post date:** [September 3, 2015, 9:56am UTC](https://forum.glyphsapp.com/t/batch-export/1383/19 "2015-09-03T09:56:44Z")

</div>

> [@Mark](#):
>
> Undusting this for something maybe related: Is it possible to access the Generate Instances via scripting? I am not seeking the instance method from the documentation here, but rather the ability to actually get the files ready for saving, with all the color labels etc. Basically exactly as the File \> Generate Instances behaves.

```
myInstance = thisFont.instances[0]
newFont = thisFont.interpolateInstance_error_(myInstance,None)
Glyphs.fonts.append(newFont)

```

---

<div class="post-metadata">

**Author:** ![Mark](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/mark/32/20784_2.png) [@Mark](https://forum.glyphsapp.com/u/Mark)\
**Post date:** [September 4, 2015, 7:21am UTC](https://forum.glyphsapp.com/t/batch-export/1383/20 "2015-09-04T07:21:19Z")

</div>

> [@mekkablue](#):
>
> The one thing does not have much to do with the other. Does the Master name matter for what you want to do?

So what is the cause for this behaviour then? The master name matters indeed, that’s why I figured this issue. Basically I need single font files that represent the very instances for a certain script. At the moment I have to check all generated files if their (now) master names equal their (previous) instance names.

[Next page](https://forum.glyphsapp.com/t/batch-export/1383.md?page=2)
