The following was the code:
Directory[]
NotebookDirectory[]
The output was
"/media/Dataholder/final"
"/media/Dataholder/final/"
In the second case, there is a trailing "/" (I am on Mathematica 8 on Ubuntu)
Just curious, why is there a difference ? Is is specific to my machine ?
I found this when this was breaking the code, wherein I wanted to change the working directory to another one relative to the current directory, i.e. using
simFldr = Directory[] <> "anotherSubDirectory"
Though this sounds trivial, the patchwork needed to get to that directory will be non trivial since I have a code which must work both on Windows and Unix.
Any smart solution to set the directory to a subdirectory ?
ToFileName
does not care about$PathnameSeparator
. Moreover, notice thatDirectory[]
is not the same asNotebookDirectory[]
unless YouSetDirectory@NotebookDirectory[]
, well, at least it is so on Win. $\endgroup$FileNameJoin
. I usually stick withStringJoin
though as it is so much easier to type. Anyway, an example:FileNameJoin[{"/Users/", "/Jacob"}]
->"/Users/Jacob"
$\endgroup$FileNameJoin[{Directory[], "lala", "hey", "folder", "file.gif"}]
and forget about it $\endgroup$