Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2012

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg125886] How to get the path of a .m file I am running?
  • From: Jesse Perla <jesseperla at gmail.com>
  • Date: Fri, 6 Apr 2012 05:52:30 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

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?

Thanks,
Jesse



  • 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?