Import file without specifying the directory

Consider a situation when we import some file in a .nb from a sub-directory located at the directory where .nb is located. We need to write specific path to the file. Next, suppose that we moved file to another directory. Then one needs to change the directory of the the file in .nb.

Is there any way to allow Mathematica to import the file simply by its name, without the specification of its location? I.e., to set up the file name and that the file is located somewhere in the .nb directory.

• Have you tried using NotebookDirectory[] to refer to the the directory the notebook is currently in? You can use FileNameJoin to build up paths from there. – Sjoerd Smit Sep 12 '18 at 11:03
• @SjoerdSmit : I move not the notebook, but the file which I want to import from sub-directory A to sub-directory B. And I don't want each time to change the sub-directory in SetDirectory[]; – John Taylor Sep 12 '18 at 11:19
• In that case, I recommend you look up the documentation for FindFile. – Sjoerd Smit Sep 12 '18 at 11:21
• ParentDirectory together with NotebookDirectory might be helpful. – Αλέξανδρος Ζεγγ Sep 12 '18 at 12:28
• Does FileNames["file.ext", NotebookDirectory[], Infinity] do what you're after? – Lukas Lang Sep 12 '18 at 14:35