MathGroup Archive 1999

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

Search the Archive

Re: Directory of the open notebook

  • To: mathgroup at smc.vnet.net
  • Subject: [mg20957] Re: Directory of the open notebook
  • From: Ben Stanley <bds02 at uow.edu.au>
  • Date: Wed, 1 Dec 1999 01:50:24 -0500 (EST)
  • Organization: http://www.uow.edu.au
  • References: <812ahm$1h8@smc.vnet.net> <81a0a4$8oe@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

OK, I tried this, and it didn't work the first time:

In[37]:=
DirectoryName[
  ToFileName["FileName" /. NotebookInformation[EvaluationNotebook[]]]]

Out[37]=
""

What? Nothing?

In[30]:=
NotebookInformation[EvaluationNotebook[]]

Out[30]=
\!\({"FileName" -> "Excercises.nb",
    "FileModificationTime" -> 3.152477493`*^9,
    "WindowTitle" -> "Excercises.nb",
    "MemoryModificationTime" -> 3.152554485095`*^9}\)

The problem seems to be that the NotebookInformation doesn't return any directory
information.

Now, I'm running on Linux, and I did cd to the directory of the notebook before I tried
this.

However, if I run mathematica from some other directory, and then re-evaluate the notebook,
I get this:

In[4]:=
dirName = DirectoryName[
  ToFileName["FileName" /. NotebookInformation[EvaluationNotebook[]]]]

Out[4]=
"/home/ben/SignalProcessing/DRSaSSP/ch2/"

This is the correct output. I suppose that if you were to feed it back into a SetDirectory[]
command, both outputs would generate the desired result. I tried that, and found that if you
use SetDirectory[] with an empty string, it gets upset. So I used

If[StringLength[dirName] > 0,
  SetDirectory[dirName]
]

Ben Stanley.





  • Prev by Date: Re: Directory of the open notebook
  • Next by Date: Maximizing Recursive Functions
  • Previous by thread: Re: Directory of the open notebook
  • Next by thread: Maximizing Recursive Functions