# to-file

## Interface

```typescript
interface parser {
  name: 'to-file';
  options: {
    filenameTemplate: string;
  };
  output: {
    type: 'directory';
    directoryPath: string;
  };
};
```

## Options

<table data-full-width="true"><thead><tr><th width="221">Parameter</th><th width="100">Required</th><th width="100">Type</th><th width="483">Default</th><th width="507">Description</th></tr></thead><tbody><tr><td><code>filenameTemplate</code></td><td><code>false</code></td><td><code>string</code></td><td><code>"{{parents}}/{{name}}[-{{mode}}]{{extension}}"</code></td><td>The mustache template used to generate the file path to write to the file system.<br>Available variables:<br><code>parents</code>: group and collection names of the token's parents<br><code>name</code>: the name of the asset token<br><code>mode</code>: the name of the current mode<br><code>extension</code>: the file extension extracted from the token</td></tr></tbody></table>

## Basic usage

{% tabs %}
{% tab title="Input" %}
{% code lineNumbers="true" %}

```json
{
  "fonts": {
    "inter-regular": {
      "$type": "font",
      "$value": {
        "default": {
          "family": "Inter Regular",
          "postScriptName": "Inter Regular",
          "weight": "regular",
          "style": "normal",
          "files": [
            {
              "format": "ttf",
              "url": "https://static.specifyapp.com/sdtf-seeds/inter-regular.ttf",
              "provider": "Specify"
            }
          ]
        }
      }
    }
  }
}
```

{% endcode %}
{% endtab %}

{% tab title="Config" %}
{% code title=".specifyrc.json" lineNumbers="true" %}

```json
{
  "version": "2",
  "repository": "@organization/repository",
  // Only use the personalAccessToken when working with the CLI
  "personalAccessToken": "<your-personal-access-token>",
  "rules": [
    {
      "name": "Generate images",
      "parsers": [
        {
          "name": "to-file",
          "options": {
            "filenameTemplate": "{{name}}{{extension}}"
          },
          "output": {
            "type": "directory",
            "directoryPath": "public"
          }
        }
      ]
    }
  ]
}
```

{% endcode %}
{% endtab %}

{% tab title="Output" %}
This will generate the corresponding font file binary, named after the `filenameTemplate`.

* public/inter-regular.ttf
  {% endtab %}
  {% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.specifyapp.com/reference/parsers/to-file.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
