MathGroup Archive 2008

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

Search the Archive

Re: Path to *.m file

  • To: mathgroup at
  • Subject: [mg86386] Re: Path to *.m file
  • From: Albert Retey <awnl at>
  • Date: Mon, 10 Mar 2008 02:02:52 -0500 (EST)
  • References: <fr0cr7$ekp$>


> is there a way to  obtain the full path to a *.m file from within that 
> same file under Mathematica 6?

This gives the filename of the *.m file:


but if you put the file into one of the directories in $Path and load it 
with e.g.:

<< tst.m


<< tst`

you might get only a relative path, that is relative to one of the 
directories in $Path. This will give you the full path in that case:

First[FileNames["tst.m", $Path]]

I have not found a function which gives you the full path directly, but 
that does not mean it doesn't exist, probably someone else has found it :-)

this is how it could look like, it should handle the common cases, but 
it's not thoroughly tested for all OS and exotic cases:

myfullpath = Catch[If[



  • Prev by Date: FindFit issue
  • Next by Date: Re: Re: NDSolve Question
  • Previous by thread: Re: Path to *.m file
  • Next by thread: Re: Path to *.m file