# Get (<<) Evaluate File Name

This seems like a simple question due to lack of experience, but I can't seem to find an answer through searching. I am trying to read back a symbol from a DumpSave:

DumpSave[NotebookDirectory[] <> "mySymbol.mx", mySymbol]

Here, using NotebookDirectory[] got my file in the current directory like I wanted, but when I try to use either of the following with Get, it fails:

<< NotebookDirectory[] <> "DiscreteTreatmentRegion.mx";
<< Evaluate[NotebookDirectory[] <> "Mysymbol.mx"];


It seems to me like it is not evaluating the filename correctly, since since it gives the message 'Cannot open ("NotebookDirectory[]").'

How can I get this to work? Or is there a better way to do what I am trying to do.

• This << (NotebookDirectory[] <> "defs.mx") works for me in a similar situation. Try closing MMA, then loading the notebook in question and running your second line again. Obviously the notebook needs to be saved. – LLlAMnYP Dec 8 '15 at 10:13
• StringJoin (<>) binds more loosely than Get (<<), it appears. the first example is interpreted as Get[NotebookDirectory[]] <> "file.mx", but the second line with Evaluate should work properly. – LLlAMnYP Dec 8 '15 at 10:17

<< is one of a few special operators which turn everything that follows into a string, without having to use quotes.

Thus << asd is just another notation for Get["asd"]. Note that the first form has no quotation marks. Illustration:

The answer to your problem is: use the Get form, and not <<, if the file name is computed as an expression. << is a convenient shorthand for when you type the file name directly.

Some other stringifying operators are >>, >>>, ::, and since version 10, #. #asd is the same as Slot["asd"].

This is documented under the "File Names" section here.

• I was trying to find good reference in docs for that. Are you aware of any? ps. NotebookDirectory[] was eveluate in my case but failed to get the data anyway. – Kuba Dec 8 '15 at 11:30
• @Kuba There's a mention under Details for Get: <<"name" is equivalent to <<name. The double quotes can be omitted if the name is of the form specified in "Operator Input Forms". – Szabolcs Dec 8 '15 at 11:31
• I saw that but I wouldn't say it is informative. – Kuba Dec 8 '15 at 11:32
• I see now, hmm I complain to much on docs so let me just go to say nothing more. – Kuba Dec 8 '15 at 11:35
• @Kuba I agree. I added a reference which is a bit better. It mentions which characters can terminate the string (file name). I don't know if # is different, it probably is. – Szabolcs Dec 8 '15 at 11:35