To maintain mobility of project files, I want to use relative paths in my notebooks. For example, I have a directory named "proj" and my notebook file is located in this directory. Meanwhile, I have to import something from directory "proj/data/". How do I get a relative path to "data"? I want to do this because I might move "proj" somewhere else in my file system.

  • $\begingroup$ I have marked this as a duplicate. If you feel that your question is not addressed there please tell me why. $\endgroup$ – Mr.Wizard Jan 3 '14 at 9:46

This is data directory (OS independent) :-

FileNameJoin@Append[FileNameSplit@NotebookDirectory[], "data"]
| improve this answer | |
  • 3
    $\begingroup$ Why not just FileNameJoin[{NotebookDirectory[], "data"}]? $\endgroup$ – MikeLimaOscar Jan 3 '14 at 9:31
  • $\begingroup$ Yup, somehow missed that. Thanks. $\endgroup$ – Chris Degnen Jan 3 '14 at 9:52

Not the answer you're looking for? Browse other questions tagged or ask your own question.