I have a package that gets loaded in many notebooks I use, with
Import[pathToLibraryDirectory<> "toolkit.m"];
This toolkit in turn loads some Excel spreadsheets that contain reference data. I prefer to keep this data external for reasons of supportability and ease in updating as new reference data is released.
The excel files live in a directory at the same level in the file structure as the directory that contains the toolkit.
The toolkit contains therefore
sheetICareAbout=Import[NotebookDirectory[]<> "..\\reference tables\\excel data notebook.xls"][[2]];
and this works if I open the toolkit and execute this line by hand, but it doesn't work if I save the toolkit as a package and load it that way. The NotebookDirectory call no longer points to the right thing. I can put in an absolute path to the directory that works in some cases, but I load this toolkit from different machines and operating systems, and the absolute paths don't always look the same.
Hence my question, is there some relative path I can refer to so that the package can find the excel files?
NotebookDirectory[]returns the directory of the file that is calling all this stuff, not the directory where all this stuff resides in. For that you need, as Leonid indicated,$InputFileName. – Sjoerd C. de Vries Apr 09 '14 at 18:49