({{, (RefLink[$InputFileName, paclet:ref/$InputFileName])
is a global variable whose value is the absolute file name of the input file from which input to the Wolfram Language is currently being sought.}})

OpenersNotesSection(Spacer1)Details

During the execution of <<file, (RefLink[$InputFileName, paclet:ref/$InputFileName]) is set to the absolute file name of file.

During the execution of a script file through wolframscript, (RefLink[$InputFileName, paclet:ref/$InputFileName]) is set to the absolute file name of the script file.

When input does not come from a file, or comes from an interactive session, (RefLink[$InputFileName, paclet:ref/$InputFileName]) is "".

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Loading a file:

<<ExampleData/input.m

During interactive input, (RefLink[$InputFileName, paclet:ref/$InputFileName]) is "":

$InputFileName

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[$Input, paclet:ref/$Input])  ▪  (RefLink[Get, paclet:ref/Get])  ▪  (RefLink[$Path, paclet:ref/$Path])  ▪  (RefLink[DirectoryName, paclet:ref/DirectoryName])  ▪  (RefLink[FileNameJoin, paclet:ref/FileNameJoin])  ▪  (RefLink[$BatchInput, paclet:ref/$BatchInput])  ▪  (RefLink[$CurrentLink, paclet:ref/$CurrentLink])  ▪  (RefLink[$ParentLink, paclet:ref/$ParentLink])  ▪  (RefLink[$TestFileName, paclet:ref/$TestFileName])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Naming and Finding Files, paclet:tutorial/NamingAndFindingFiles])}, {▪(RefLinkPlain[The Main Loop, paclet:tutorial/TheMainLoop])}})}})