Invoking lilypond

The lilypond executable may be called as follows from the command line.

lilypond [option]… file

When invoked with a file name that has no extension, the .ly extension is tried first. To read input from stdin, use a dash (-) for file.

Note: On Windows prior to Windows 10 1903, LilyPond cannot handle Unicode file names.

When is processed it produces filename.pdf as output by default. Several files can be specified; they are each processed independently.1

If contains more than one \book block, the rest of the scores is output in numbered files, starting with filename-1.pdf. See Output file names how to change the output file name and the file name suffix.

Using LilyPond with standard shell features

Since LilyPond is a command-line application, features of the ‘shell’ used for calling LilyPond can also be put to good use.

For example,

lilypond *.ly

processes all LilyPond files in the current directory.

Redirecting the console output (e.g., to a file) may also be useful:

lilypond 1> stdout.txt
lilypond 2> stderr.txt
lilypond &> all.txt

The above commands divert ‘normal’ output, ‘errors’ only, or ‘everything’, respectively, to text files. Consult the documentation for your particular shell, Command (Windows), Terminal or Console applications (macOS) to check whether output redirection is supported or if the syntax is different.

The following example searches and processes all input files in the current directory and all directories below it recursively. The output files are located in the same directory that the command was run in, rather than in the same directories as the original input files.

find . -name '*.ly' -exec lilypond '{}' \;

This should also work for macOS users.

A Windows user would run

forfiles /s /M *.ly /c "cmd /c lilypond @file"

entering these commands in a command prompt usually found under Start > Accessories > Command Prompt, or by typing in the search window ‘command prompt’.

Alternatively, an explicit path to the top-level of your folder containing all the sub-folders that have input files in them can be stated using the /p option;

forfiles /s /p C:\Documents\MyScores /M *.ly /c "cmd /c lilypond @file"

If there are spaces in the path to the top-level folder, then the whole path needs to be inside double quotes;

forfiles /s /p "C:\Documents\My Scores" /M *.ly /c "cmd /c lilypond @file"



The status of Guile is not reset after processing a .ly file, so be careful not to change any system defaults from within Scheme.

LilyPond Application Usage v2.25.18 (development-branch).