MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: What does NotebookDirectory[] do for .m files?

"David Bailey" <dave at>: news:jmdsop$ac3$1 at
> On 13/04/2012 10:08, Jesse Perla wrote:
>> NotebookDirectory[] correctly gives the location of the notebook for my 
>> .nb files, but I cannot seem to find an equivalent for my .m files?  Is 
>> there another approach?
> There are two distinct cases here.
> If you open a .m file in the FrontEnd, it is treated like a notebook,
> and NotebookDirectory will work on it.
> If you use Get ( << ) to open the file, or it is opened because of a
> Needs command, then things get a bit trickier. While the .m file is
> being loaded in, $InputFileName is set to the name of the .m file, but
> not to the complete path!

It seems that in version 8.0.4 $InputFileName gives complete path to the 
.m-file. Evaluating

<< ExampleData/input.m


$Input is ExampleData/input.m
$InputFileName is C:\Program Files\Wolfram 

while evaluating



Print["$Input is ",$Input];
Print["$InputFileName is ",$InputFileName];

  • Prev by Date: Anyone know of lab connectivity tools for Mathematica?
  • Next by Date: Re: What characters are allowed in mathematica variable names? i.e. how
  • Previous by thread: Re: What does NotebookDirectory[] do for .m files?
  • Next by thread: Re: What does NotebookDirectory[] do for .m files?