Getting the filename which is being typeset
![](https://secure.gravatar.com/avatar/5faea8b4fa0adb143383811dc94f0d22.jpg?s=120&d=mm&r=g)
Hi everyone, I have to typeset a few files which get each an input file named in a certain way. For instance, a file named « myfile.tex » in which another file named « myfile-buffer.tex » is used as an \input file, as in % content of myfile.tex %%%%% \starttext This is a test. \input myfile-buffer.tex \stoptext %%%%% When typesetting « myfile.tex » I wonder whether it is possible to get the name of the file without its suffix, that is to get « myfile », with a command such as \getNameOfCurrentFile and then be able to replace the above snippet by: % desired content of myfile.tex %%%%% \starttext This is a test. \input \getNameOfCurrentFile-buffer.tex \stoptext %%%%% Best regards and thanks for any hint: Otared K.
![](https://secure.gravatar.com/avatar/9c54554cf31b1a1894f2a3420f0ebbc1.jpg?s=120&d=mm&r=g)
Hi Otared, try \jobname. Best wishes, Tomáš Tue, Dec 01, 2020 ve 02:45:18PM +0100 Otared Kavian napsal(a): # Hi everyone, # # I have to typeset a few files which get each an input file named in a certain way. For instance, a file named « myfile.tex » in which another file named « myfile-buffer.tex » is used as an \input file, as in # # % content of myfile.tex # %%%%% # \starttext # This is a test. # # \input myfile-buffer.tex # \stoptext # %%%%% # # When typesetting « myfile.tex » I wonder whether it is possible to get the name of the file without its suffix, that is to get « myfile », with a command such as # \getNameOfCurrentFile # and then be able to replace the above snippet by: # # % desired content of myfile.tex # %%%%% # \starttext # This is a test. # # \input \getNameOfCurrentFile-buffer.tex # \stoptext # %%%%% # # Best regards and thanks for any hint: Otared K. # ___________________________________________________________________________________ # If your question is of interest to others as well, please add an entry to the Wiki! # # maillist : ntg-context@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 # ___________________________________________________________________________________ Tomáš Hála -------------------------------------------------------------------- Mendelova univerzita, Provozně ekonomická fakulta, ústav informatiky Zemědělská 1, CZ-613 00 Brno, tel. +420 545 13 22 28 -------------------------------------------------------------------- http://akela.mendelu.cz/~thala
![](https://secure.gravatar.com/avatar/5faea8b4fa0adb143383811dc94f0d22.jpg?s=120&d=mm&r=g)
Thanks Tomás! Indeed \jobname does the job :-) Best regards: Otared
On 1 Dec 2020, at 15:25, Tomas Hala
wrote: Hi Otared,
try \jobname.
Best wishes,
Tomáš
Tue, Dec 01, 2020 ve 02:45:18PM +0100 Otared Kavian napsal(a): # Hi everyone, # # I have to typeset a few files which get each an input file named in a certain way. For instance, a file named « myfile.tex » in which another file named « myfile-buffer.tex » is used as an \input file, as in # # % content of myfile.tex # %%%%% # \starttext # This is a test. # # \input myfile-buffer.tex # \stoptext # %%%%% # # When typesetting « myfile.tex » I wonder whether it is possible to get the name of the file without its suffix, that is to get « myfile », with a command such as # \getNameOfCurrentFile # and then be able to replace the above snippet by: # # % desired content of myfile.tex # %%%%% # \starttext # This is a test. # # \input \getNameOfCurrentFile-buffer.tex # \stoptext # %%%%% # # Best regards and thanks for any hint: Otared K. # ___________________________________________________________________________________ # If your question is of interest to others as well, please add an entry to the Wiki! # # maillist : ntg-context@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 # ___________________________________________________________________________________
Tomáš Hála -------------------------------------------------------------------- Mendelova univerzita, Provozně ekonomická fakulta, ústav informatiky Zemědělská 1, CZ-613 00 Brno, tel. +420 545 13 22 28 -------------------------------------------------------------------- http://akela.mendelu.cz/~thala ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@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 ___________________________________________________________________________________
![](https://secure.gravatar.com/avatar/5faea8b4fa0adb143383811dc94f0d22.jpg?s=120&d=mm&r=g)
Thanks Hraban, this might be also useful and I'll keep it somewhere on my mind, but for the project I was asking my question \jobname is enough. Best regards: Otared
On 1 Dec 2020, at 17:33, Henning Hraban Ramm
wrote: Am 01.12.2020 um 16:20 schrieb Otared Kavian
: Thanks Tomás! Indeed \jobname does the job :-)
In case you need the current component file in a project environment: \currentcomponent
Hraban ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@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 ___________________________________________________________________________________
![](https://secure.gravatar.com/avatar/74d41c3215dcdd377343cdc47311757c.jpg?s=120&d=mm&r=g)
Otared Kavian schrieb am 01.12.2020 um 18:10:
Thanks Hraban, this might be also useful and I'll keep it somewhere on my mind, but for the project I was asking my question \jobname is enough.
Best regards: Otared
On 1 Dec 2020, at 17:33, Henning Hraban Ramm
wrote: Am 01.12.2020 um 16:20 schrieb Otared Kavian
: Thanks Tomás! Indeed \jobname does the job :-) In case you need the current component file in a project environment: \currentcomponent
In some case \inputfilename is the better choice, e.g. when you process xml files with a environment file for the style and processing settings. context --environment=myxmlstyle myfile.xml The following example shows the output of all commands: \starttext \starttabulate [|T|T|] \NC \type{\jobname} \NC \jobname \NC\NR \NC \type{\jobfilename} \NC \jobfilename \NC\NR \NC \type{\jobfilesuffix} \NC \jobfilesuffix \NC\NR \NC \type{\inputfilename} \NC \inputfilename \NC\NR \NC \type{\inputfilebarename} \NC \inputfilebarename \NC\NR \NC \type{\inputfilesuffix} \NC \inputfilesuffix \NC\NR \NC \type{\outputfilename} \NC \outputfilename \NC\NR \NC \type{\operatingsystem} \NC \operatingsystem \NC\NR \stoptabulate \stoptext Wolfgang
![](https://secure.gravatar.com/avatar/5faea8b4fa0adb143383811dc94f0d22.jpg?s=120&d=mm&r=g)
Hi Wolfgang, Thank you for your explanations: I am wondering whether this kind of information could go into the wiki, and if yes what would be an appropriate title for that page (of course I'll do it). However the two commands \inputfilesuffix \jobfilesuffix put inside the file « myfile.tex » do not give the suffix « tex »: shoul dthey give « tex » or am I misintrepreting these commands? Best regards: Otared
On 1 Dec 2020, at 18:23, Wolfgang Schuster
wrote: Otared Kavian schrieb am 01.12.2020 um 18:10:
Thanks Hraban, this might be also useful and I'll keep it somewhere on my mind, but for the project I was asking my question \jobname is enough.
Best regards: Otared
On 1 Dec 2020, at 17:33, Henning Hraban Ramm
wrote: Am 01.12.2020 um 16:20 schrieb Otared Kavian
: Thanks Tomás! Indeed \jobname does the job :-) In case you need the current component file in a project environment: \currentcomponent
In some case \inputfilename is the better choice, e.g. when you process xml files with a environment file for the style and processing settings.
context --environment=myxmlstyle myfile.xml
The following example shows the output of all commands:
\starttext \starttabulate [|T|T|] \NC \type{\jobname} \NC \jobname \NC\NR \NC \type{\jobfilename} \NC \jobfilename \NC\NR \NC \type{\jobfilesuffix} \NC \jobfilesuffix \NC\NR \NC \type{\inputfilename} \NC \inputfilename \NC\NR \NC \type{\inputfilebarename} \NC \inputfilebarename \NC\NR \NC \type{\inputfilesuffix} \NC \inputfilesuffix \NC\NR \NC \type{\outputfilename} \NC \outputfilename \NC\NR \NC \type{\operatingsystem} \NC \operatingsystem \NC\NR \stoptabulate \stoptext
Wolfgang
___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@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 ___________________________________________________________________________________
![](https://secure.gravatar.com/avatar/46562c7d27388490d62e8d7a5bc960dd.jpg?s=120&d=mm&r=g)
On 12/1/2020 6:55 PM, Otared Kavian wrote:
Hi Wolfgang,
Thank you for your explanations: I am wondering whether this kind of information could go into the wiki, and if yes what would be an appropriate title for that page (of course I'll do it).
However the two commands
\inputfilesuffix \jobfilesuffix
put inside the file « myfile.tex » do not give the suffix « tex »: shoul dthey give « tex » or am I misintrepreting these commands? tex is the default suffix in engines
Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/880e9a15b17a0bf7159f4e31030a9be2.jpg?s=120&d=mm&r=g)
Am 01.12.2020 um 18:23 schrieb Wolfgang Schuster
: The following example shows the output of all commands:
\starttext \starttabulate [|T|T|] \NC \type{\jobname} \NC \jobname \NC\NR \NC \type{\jobfilename} \NC \jobfilename \NC\NR \NC \type{\jobfilesuffix} \NC \jobfilesuffix \NC\NR \NC \type{\inputfilename} \NC \inputfilename \NC\NR \NC \type{\inputfilebarename} \NC \inputfilebarename \NC\NR \NC \type{\inputfilesuffix} \NC \inputfilesuffix \NC\NR \NC \type{\outputfilename} \NC \outputfilename \NC\NR \NC \type{\operatingsystem} \NC \operatingsystem \NC\NR \stoptabulate \stoptext
On MacOS 10.13 the result of \operatingsystem is „osx-ppc“. That was a surprise:-) Greetings Axel
![](https://secure.gravatar.com/avatar/46562c7d27388490d62e8d7a5bc960dd.jpg?s=120&d=mm&r=g)
On 12/4/2020 8:02 AM, Axel Kielhorn wrote:
Am 01.12.2020 um 18:23 schrieb Wolfgang Schuster
: The following example shows the output of all commands:
\starttext \starttabulate [|T|T|] \NC \type{\jobname} \NC \jobname \NC\NR \NC \type{\jobfilename} \NC \jobfilename \NC\NR \NC \type{\jobfilesuffix} \NC \jobfilesuffix \NC\NR \NC \type{\inputfilename} \NC \inputfilename \NC\NR \NC \type{\inputfilebarename} \NC \inputfilebarename \NC\NR \NC \type{\inputfilesuffix} \NC \inputfilesuffix \NC\NR \NC \type{\outputfilename} \NC \outputfilename \NC\NR \NC \type{\operatingsystem} \NC \operatingsystem \NC\NR \stoptabulate \stoptext
On MacOS 10.13 the result of \operatingsystem is „osx-ppc“. That was a surprise:-)
maybe apples are no longer apples because we cannot check for some env variable directly (at least we could not reliable when the code was written) a slower echo is used to check $HOSTTYPE and if we don't recognize something there we end up with a ppc because that was what osx started with now, in practice this is not that important because most systems don't distinguish between 32/64 or some mix wrt paths (i might actually remove a lot of that stuff because in luamatetex we're more normalized across platforms) the apple guesser is tricky because at least in the past there was no reliable way to figure it out, for instance uname didn't work well and we had this curious mix of 64 bit machines that osx refused to see as such (i remember that I had to root something in the old macbook to make it being seen as 64 bit instead of 32 in order to be able to update) what does your "echo $HOSTTYPE" mention? Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
![](https://secure.gravatar.com/avatar/880e9a15b17a0bf7159f4e31030a9be2.jpg?s=120&d=mm&r=g)
Am 04.12.2020 um 10:04 schrieb Hans Hagen
: On 12/4/2020 8:02 AM, Axel Kielhorn wrote:
Am 01.12.2020 um 18:23 schrieb Wolfgang Schuster
: The following example shows the output of all commands:
\starttext \starttabulate [|T|T|] \NC \type{\jobname} \NC \jobname \NC\NR \NC \type{\jobfilename} \NC \jobfilename \NC\NR \NC \type{\jobfilesuffix} \NC \jobfilesuffix \NC\NR \NC \type{\inputfilename} \NC \inputfilename \NC\NR \NC \type{\inputfilebarename} \NC \inputfilebarename \NC\NR \NC \type{\inputfilesuffix} \NC \inputfilesuffix \NC\NR \NC \type{\outputfilename} \NC \outputfilename \NC\NR \NC \type{\operatingsystem} \NC \operatingsystem \NC\NR \stoptabulate \stoptext On MacOS 10.13 the result of \operatingsystem is „osx-ppc“. That was a surprise:-) maybe apples are no longer apples
They lost the Power when they became Intelligent, and now they get ARMed.
because we cannot check for some env variable directly (at least we could not reliable when the code was written) a slower echo is used to check $HOSTTYPE and if we don't recognize something there we end up with a ppc because that was what osx started with
now, in practice this is not that important because most systems don't distinguish between 32/64 or some mix wrt paths (i might actually remove a lot of that stuff because in luamatetex we're more normalized across platforms)
the apple guesser is tricky because at least in the past there was no reliable way to figure it out, for instance uname didn't work well and we had this curious mix of 64 bit machines that osx refused to see as such (i remember that I had to root something in the old macbook to make it being seen as 64 bit instead of 32 in order to be able to update)
what does your "echo $HOSTTYPE" mention?
Melora:~ axel$ echo $HOSTTYPE x86_64 Melora:~ axel$ uname -a Darwin 17.7.0 Darwin Kernel Version 17.7.0: Fri Oct 30 13:34:27 PDT 2020; root:xnu-4570.71.82.8~1/RELEASE_X86_64 x86_64 This computer thinks it is Intel based. Greetings Axel
participants (6)
-
Axel Kielhorn
-
Hans Hagen
-
Henning Hraban Ramm
-
Otared Kavian
-
Tomas Hala
-
Wolfgang Schuster