Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

On OSX at least, it's possible to quickly retrieve a folder/file path by dragging & dropping the folder/file into the terminal, eg:

enter image description here

Is it possible to program Mathematica's front end enable similar drag & drop operation? I'm primarily interested in passing path info to Import and Export.

share|improve this question
What kind of content do you want to drag and drop? It works for Images. I am not exactly sure what action Mathematica should take when you drag and drop an arbitrary file. Do you just want the file's name to appear as a string? – Searke Jul 16 '12 at 20:49
That's an interesting question. On Windows 7 that drag yields a list of file names within the folder. Is that what you get also? – Mr.Wizard Jul 16 '12 at 20:50
The file's path. Editing post to refer to Import/Export – alancalvitti Jul 16 '12 at 20:52
Also you get strings for files that are text files. A text file containing {1,2,3,4} yields "{1,2,3,4}". Some drag and drop functionality is already implemented. It would be probably wise to avoid actually overloading it. – Searke Jul 16 '12 at 20:52
up vote 9 down vote accepted

On Mac OS 10.7 just holding down the Option key while you drag works.

share|improve this answer
Excellent, that works. Is that documented? – alancalvitti Jul 16 '12 at 20:54
Yes check out 'howto/InsertAFilePath' – M.R. Jul 16 '12 at 20:54
On Windows one should hold down the Ctrl+Shift keys when releasing the mouse button. The cursor will change to indicate that a path will be inserted when you release the mouse button. – Alexey Popkov Jul 17 '12 at 5:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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