2.2 Invoking convert-ly

The convert-ly command uses the \version number in the input file to detect older versions. In most cases, to upgrade your input file it is sufficient just to run;

convert-ly -e myfile.ly

in the directory containing the input file. This will upgrade ‘myfile.ly’ in-place and preserve the original file by renaming it ‘myfile.ly~’. The \version number in the upgraded input file, along with any required syntax updates, is also changed.

When run, the convert-ly command will output the version numbers of which conversions have been made to. If no version numbers are listed in the output for the file, it is already up to date and using the latest LilyPond syntax.

Note: For each new version of LilyPond, a new convert-ly command is created, however not every version of LilyPond will need syntax changes for its input files from the version before. This means that the convert-ly command will only convert input files up to the latest syntax change it has and this, in turn, may mean that the \version number left in the upgraded input file is sometimes earlier than the version of convert-ly command itself.

To convert all input files in a single directory use;

convert-ly -e *.ly

Linux and MacOS X users can both use the appropriate terminal application, but MacOS X users can also execute this command directly under the menu entry Compile > Update syntax.

A Windows user would run the command;

convert-ly.py -e *.ly

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

To convert all input files that reside in different sets of subdirectories;

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

This example searches and converts all input files in the current directory and all directories below it recursively. The converted files will be located in the same directory along with their renamed originals. This should also work for MacOS X users, although only via the terminal app.

Windows user would use;

forfiles /s /M *.ly /c "cmd /c convert-ly.py -e @file"

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 convert-ly.py -e @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 convert-ly.py -e @file"

LilyPond — Usage v2.24.3 (stable-branch).