Thanks for your reply, Timothy.  But "(ly:parser-output-name)” does not appear 
to have the -o applied to it.  It looks like, because I’m specifying a 
directory with -o, it is changing the working directory instead of prepending 
it to the parser-output-name.

#######

\version "2.24"

#(format #t "\nly:parser-output-name: ~a\n" (ly:parser-output-name))
#(format #t "basename: ~a\n" (basename (ly:parser-lookup 'input-file-name) 
".ly"))

{
  c'1
}

#######

% lilypond -o "build/" OutputOption.ly
GNU LilyPond 2.25.26 (running Guile 3.0)
Changing working directory to: `build'
Processing `OutputOption.ly'
Parsing...
ly:parser-output-name: OutputOption
basename: OutputOption

Interpreting music...
Preprocessing graphical objects...
Finding the ideal number of pages...
Fitting music on 1 page...
Drawing systems...
Converting to `OutputOption.pdf'...
Success: compilation successfully completed

#######

David

> On Jan 18, 2026, at 9:54 AM, Timothy Lanfear <[email protected]> wrote:
> 
> On 17/01/2026 23:20, David F. wrote:
>> Thanks, Knute.  I am aware of those, but they don’t quite get me what I 
>> want.  If I hardcode the output directory with \bookOutputName, then it 
>> can’t be overridden from the command line.
> I'm not sure if this covers exactly your use case but should be easily 
> adaptable if not. Check the input and output file names. If they match the -o 
> option has not been used, in which case bookOutputName is called to change 
> the output file name.
> 
> \version "2.24.0"
> 
> #(let* ((opfile (ly:parser-output-name))
>         (ipfile (basename (ly:parser-lookup 'input-file-name) ".ly")))
>   (when (string=? ipfile opfile)
>     #{ \bookOutputName "newname" #}))
> 
> {
>   c'1
> }
> 
> 
> -- 
> Timothy Lanfear, Bristol, UK.

Reply via email to