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: email@example.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