# 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:** 2

<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:23am UTC](https://forum.glyphsapp.com/t/batch-export/1383/21 "2015-09-04T07:23:19Z")

</div>

> [@mekkablue](#):
>
> myInstance = thisFont.instances[0]  
> newFont = thisFont.interpolateInstance\_error\_(myInstance,None)  
> Glyphs.fonts.append(newFont)

Thanks so much!

And what are the arguments for `saveToFile_error_(…, …)`? I guess the second one can be `None` and the first might be filePath? All I tried spits depythonifying ‘pointer’ errors out.

---

<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 8, 2015, 1:32pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/22 "2015-09-08T13:32:09Z")

</div>

And another related one: Is it possible to make use of anything alike the following but without closing all fonts?

```
Glyphs.closeAll_(Glyphs.fonts)

```

Indexing doesn’t do the trick and other closing functions cannot be found in the help(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:** [September 8, 2015, 6:51pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/23 "2015-09-08T18:51:00Z")

</div>

There is a `GSFont.close()` method. It was missing from the docu. It accepts one parameter: `ignoreChanges` that controls if it asks to save changes.

---

<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 9, 2015, 6:15am UTC](https://forum.glyphsapp.com/t/batch-export/1383/24 "2015-09-09T06:15:36Z")

</div>

Thanks Georg! That is some treat. Now I got the puzzle almost complete, only the last two pieces are missing from the yet open questions posted above [master name and saveToFile\_error\_()]. I would be grateful if anybody could help me out with these.

---

<div class="post-metadata">

**Author:** ![MDomino](https://forum.glyphsapp.com/letter_avatar_proxy/v4/letter/m/5daacb/32.png) [@MDomino](https://forum.glyphsapp.com/u/MDomino)\
**Post date:** [September 13, 2015, 4:22pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/25 "2015-09-13T16:22:02Z")

</div>

Hello there,  
I am trying pretty much the same thing as Mark does with the UFOs, however, I wanted to change mine back to .otf files. When I change the code back, though, it does not export anymore and gives me “Result: 0”. What am I doing wrong? (as you can see, I am renaming the familyNames in the process, but that should not be a problem, should it?)

Oh, and I also had to comment out Exporter.setFontMaster\_(Master), since it gave me an error when trying .otf. Is this the problem, maybe?

```
Exporter = NSClassFromString("GlyphsFileFormatOTF").alloc().init()
for i, f in enumerate(Glyphs.fonts):
    print f
    f.familyName = "myFamilyName" + str(i)
    Master = f.fontMasters()[0]
    #Exporter.setFontMaster_(Master)
    FilePath = f.parent.fileURL().path()
    FilePath = FilePath.replace(".glyphs", "-"+Master.name+".otf")
    Result = Exporter.writeFont_toURL_error_(f, NSURL.fileURLWithPath_(FilePath) , None)
    print "Result:", Result

```

Thanks in advance!

MD

Oh, and I am using Glyphs 1, since I am still on OS 10.8.5.

---

<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:** [September 13, 2015, 6:44pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/26 "2015-09-13T18:44:39Z")

</div>

> [@MDomino](#):
>
> Oh, and I also had to comment out Exporter.setFontMaster\_(Master), since it gave me an error when trying .otf. Is this the problem, maybe?

the OTF exporter has no fontMaster property. It always exports the first master, so you need to get an instance if you have more then one master.

> [@MDomino](#):
>
> Result = Exporter.writeFont\_toURL\_error\_(f, NSURL.fileURLWithPath\_(FilePath) , None)

this is not implemented. You can use this:

```auto
Exporter = NSClassFromString("GlyphsFileFormatOTF").alloc().init()
for i, f in enumerate(Glyphs.fonts):
    print f
    f.familyName = "myFamilyName" + str(i)
    Exporter.setFont_(f)
    FilePath = f.filepath.stringByDeletingLastPathComponent()
    Result = Exporter.exportToURL_error_(NSURL.fileURLWithPath_(FilePath), None)
    print "Result:", Result

```

You can’t set the actually filename of the font, it will be computed from the family and style name or set by a custom parameter.

---

<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 14, 2015, 9:11am UTC](https://forum.glyphsapp.com/t/batch-export/1383/27 "2015-09-14T09:11:41Z")

</div>

So still no way to save the actual .glyphs file via script?

---

<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:** [September 14, 2015, 12:47pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/28 "2015-09-14T12:47:05Z")

</div>

> [@Mark](#):
>
> So still no way to save the actual .glyphs file via script?

There is: `GSFont.save('path')`

---

<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 14, 2015, 3:04pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/29 "2015-09-14T15:04:39Z")

</div>

While

```
thisFont = Glyphs.fonts[0]
thisFont.close()

```

works, unfortunately this one doesn’t work:

```
thisFont.save('WhateverPathWeTryHere')

```

–\> AttributeError: ‘NSKVONotifying\_GSDocument’ object has no attribute ‘typeName’

---

<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 16, 2015, 7:43am UTC](https://forum.glyphsapp.com/t/batch-export/1383/30 "2015-09-16T07:43:23Z")

</div>

Any help please? `.save('path')` is not working here (s. a.). How to apply it, please? Using `.save()` without anything passed as parameter actually saves the font itself just fine, but I need to save it to a path, and this is exactly what doesn’t seem to work somehow.

---

<div class="post-metadata">

**Author:** ![robu](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/robu/32/15938_2.png) [@robu](https://forum.glyphsapp.com/u/robu)\
**Post date:** [September 16, 2015, 8:45am UTC](https://forum.glyphsapp.com/t/batch-export/1383/31 "2015-09-16T08:45:13Z")

</div>

While you’re talking about exporting…  
Is it possible to make Glyphs remember the exporting location for each individual file. I’m working on different fonts at the same time and each time I’m exporting I have to change the folder…

---

<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 16, 2015, 4:16pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/32 "2015-09-16T16:16:15Z")

</div>

I always export it into the Adobe Fonts folder and from there, in the finder (list mode, sorted by Date added), copy the fonts to the locations I need (usually more than one). If I need it very often, I set up a folder action.

---

<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 17, 2015, 9:49am UTC](https://forum.glyphsapp.com/t/batch-export/1383/33 "2015-09-17T09:49:41Z")

</div>

and the `.save()`? sorry for bumping.

---

<div class="post-metadata">

**Author:** ![Bernto](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/bernto/32/32947_2.png) [@Bernto](https://forum.glyphsapp.com/u/Bernto)\
**Post date:** [October 13, 2015, 4:49pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/34 "2015-10-13T16:49:39Z")

</div>

Is there a way to access the production names in a script? That UFO batch export script is almost what I need, but how can I use production names in it?

---

<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:** [October 13, 2015, 8:16pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/35 "2015-10-13T20:16:34Z")

</div>

What exactly does the script what the ufo-export can’t?  
The UFO exporter can be configured to export with production names. Or, if you like to do it yourself you can ask the glyph for its `productionName()` (it is not in the wrapper, so it needs the parenthesis). If it is not set, use `GSGlyphsInfo.productionGlyphNameForGlyph_(glyph)`.

---

<div class="post-metadata">

**Author:** ![Bernto](https://forum.glyphsapp.com/user_avatar/forum.glyphsapp.com/bernto/32/32947_2.png) [@Bernto](https://forum.glyphsapp.com/u/Bernto)\
**Post date:** [October 14, 2015, 12:51pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/36 "2015-10-14T12:51:28Z")

</div>

The script batch exports all opened fonts as UFO, whilst the ufo-export only exports masters of a glyph file.  
I would like to export instances as UFO with production names.

---

<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:** [January 11, 2016, 11:01am UTC](https://forum.glyphsapp.com/t/batch-export/1383/37 "2016-01-11T11:01:13Z")

</div>

A)  
Is the function [`generate()`](http://docu.glyphsapp.com/#generate) already implemented? I tried in the newest cutting edge and cannot make it work, neither given any errors.

B)  
Would it be possible to generate as web fonts as well with it? If not, how to do that via code?

---

<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:** [January 12, 2016, 4:15pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/38 "2016-01-12T16:15:11Z")

</div>

With doing the following, I always end up getting a `.ttf` no matter what FileType I specify:

```
for i, instance in enumerate(Glyphs.font.instances):
	if i == 0:
		instance.generate(["OTF"])

```

What is going on?

---

<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:** [January 12, 2016, 5:09pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/39 "2016-01-12T17:09:05Z")

</div>

Do you have a custom parameter that forces TrueType?  
I’ll have a look at the generate method.

---

<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:** [January 12, 2016, 5:14pm UTC](https://forum.glyphsapp.com/t/batch-export/1383/40 "2016-01-12T17:14:51Z")

</div>

Interesting Tipp. Unfortunately not. I even tried with a clean, new file. Same thing.

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

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