# Pathname Substitution Strings and Command Script Variables

TVH has the ability to build a recording file and path name using predefined substitution strings. For example, using `$t` will include the EPG Title in the file name. Likewise, `%t` will pass the EPG Title as a command line argument to one of the DVR Profile command scripts.

This feature is implemented in `src/dvr/dvr_rec.c`.

A number of `htsstr_substitute_t` arrays contain a list of substitution identifiers and the functions required to perform the required substitution.

The actual substitution is performed by `htsstr_substitute` (`src/htsstr.c`) which is passed a substitution array and a substitution key (`$` or `%`) as well as an output variable.

Pathname substitution strings can be applied equally to the file name and to directories in the hierarchy under the base directory specified in the DVR Profile. It should be noted, however, that objects that can provide their own directories, such as AutoRec and Timer DVR objects, must have their directory prefixed with `$$` for substitutions to take place. The `$$` prefix will be omitted from the final directory name.


---

# 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.tvheadend.org/documentation/development/pathname-substitution-strings-and-command-script-variables.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.
