20.4 Output file names

It is possible to override both the output file name and the suffix appended to the basic file name in \paper blocks.

\paper {
  output-filename = "my_special_output"
}

\book {
  \paper {
    output-suffix = "menuetto"
  }
  ...
}
\book {
  \paper {
    output-suffix = "scherzo"
  }
  ...
}

The result are two output files named my_special_output-menuetto.pdf and my_special_output-scherzo.pdf. Be careful to select values for output-filename and output-suffix that are valid for file names on your operating system!

If this output file name already exists (this can happen, for example, if both output-filename and output-suffix are set in the global \paper block and not in any \book blocks), LilyPond appends an additional suffix with an increasing number.

output-filename and output-suffix can also be set in a \midi block to name the MIDI file generated from that block, which allows creating several MIDI files from a single score. A variable that is not set in the \midi block is taken from the book. In particular, an output-suffix set in a \midi block replaces the suffix of the book instead of being appended to it; use ##f to get no suffix at all.

\score {
  ...music...
  \midi {
    output-suffix = "rehearsal"
    \context {
      \Score
      tempoWholesPerMinute = #(ly:make-moment 80 4)
    }
  }
  \midi { output-suffix = ##f }
}

In source file eightminiatures.ly, this produces eightminiatures-rehearsal.midi and eightminiatures.midi.

MIDI files are numbered independently of the printed output. If several MIDI files would get the same name, LilyPond appends an increasing number to the names. This number is always present if the output file name of the book has been given one, so the MIDI files of the second of two books in test.ly are named test-1-1.midi, test-1-2.midi, and so on, after test.midi and test-1.midi of the first book.

Note that predefined \paper variables (see The \paper block) must be placed before the output-filename and output-suffix assignments, for example

bigMargin = \paper { top-margin = 10\cm }

\book {
  \paper {
    \bigMargin % must come first
    output-filename = "foo"
  }
}

LilyPond Notation Reference v2.27.5 (development-branch).