3

I get get notebook location with NotebookDirectory\[\]

How to get m-file location from within it?

Dims
  • 735
  • 3
  • 12

1 Answers1

5

You can use

DirectoryName[$InputFileName]
C. E.
  • 70,533
  • 6
  • 140
  • 264
  • 4
    @Dims It is good to know that this works only if evaluated while the file is being loaded. A common mistake is to define packDir[] := DirectoryName[$InputFileName] in the package, then try to use packDir[] after the package has already loaded. Instead, do $packDir = DirectoryName[$InputFileName]; packDir[] := $packDir in the package. – Szabolcs Oct 18 '17 at 17:37