MathGroup Archive 2012

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

Search the Archive

How to get the path of a .m file I am running?

I have a mathematica .m file that I am running on the command line (as well as in the IDE for debugging).

I want to get the path that it is run from so that I can store output files relative to it.  It seems that if I run the file from the command line that $InitialDirectory gives me what I want, but when I Right-Click Open on my desktop to view it in the Mathematica IDE, $InitialDirectory gives me something else.....

It looks like there is a function called NotebookDirectory[] which works for .nb's, but not for .m's....

Is there any trick to do the equivalent for .m?


  • Prev by Date: Stuck solving recurrence formula
  • Next by Date: Re: fyi, small note on using Mathematica for object based programming
  • Previous by thread: Re: Stuck solving recurrence formula
  • Next by thread: Why does ModuleQ[{0,1,2}, expr_] evaluate to True?