[NTG-context] how to set the name of outputfile using a value defined in the source

Henri Menke henrimenke at gmail.com
Fri Sep 21 10:30:34 CEST 2018

On 21/09/18 20:09, J Huisman wrote:
> Hi all,
> I'm getting back to using ConTeXt after a couple of years, so I might
> be missing something obvious...
> I would like to add an I.D. code to the name of my outputfile, but
> since this will be used in an automated environment I would like to
> load the ID-code from the source file.
> MWE: test.tex
> \starttext
> \def\idcode{something}
> Some text, whatever.
> \stoptext
> If I typeset with: context text --result=test-idcode the result is
> obviously "test-idcode.pdf", but I want to get a file name:
> "test-something.pdf"
> Is this possible?

Once you enter TeX, the output file has been opened.  The very concept
of a filesystem forbids you to change the filehandle while writing.  So
no, it is not possible easily.

You could still do it, but it would require two passes.  In the first
pass to identify that you want to change the output file and write the
new name to an auxiliary file.  In the second file, you use your
automation script to read that file back in and call

context --result=test-<value read from file> test.tex

> Thanks,
> Jelle
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> maillist : ntg-context at ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

More information about the ntg-context mailing list