Pop Up for Setting directory path

I am trying to build certain modules in Mathematica 9. I want it to dynamically ask for the directory path ( like file explorer ) when the code cell is executed.

How can I do that ?

(*================================================= DIRECTORY CONTROL \============================================*)

Directory[];
(*current directory*)
SetDirectory[NotebookDirectory[]];(*set to local roaming directory *)

SetDirectory[“File_Directory”];
(* set to local roaming SubDirectory *)

=================

  

 

@rm-rf -rf Thank you. How can I enable the pop up by default. Shift+Enter should display the folder Browser window. Is there a method to do that ?
– abhilash sukumari
Apr 24 ’13 at 21:58

=================

2 Answers
2

=================

To choose the directory interactively, use SystemDialogInput, which brings up a native dialog

SystemDialogInput[“Directory”]

If successful, it’ll return the chosen directory as a string, or return $Canceled if you select “Cancel”.

  

 

Exactly what I want.
– abhilash sukumari
Apr 24 ’13 at 22:04

  

 

thanks @rm -rf …
– abhilash sukumari
Apr 24 ’13 at 22:04

  

 

Any way to add custom message like : choose the sub folder or choose the subsubfolder … It may create confusion when more than one such dialog pop up right …
– abhilash sukumari
Apr 24 ’13 at 22:10

  

 

It would be bad UX to have multiple popups appearing at the same time for such a simple (and common) operation. Instead, if you’re using something like a Button[] for your interface, consider a descriptive name for the button, such as Button[“Choose directory”, dir = SystemDialogInput[“Directory”]]
– R. M.♦
Apr 24 ’13 at 22:13

  

 

Ok sounds good. Thanks a lot !
– abhilash sukumari
Apr 24 ’13 at 22:17

Extending R.M’s answer:

Button[“Choose directory”, dir = SystemDialogInput[“Directory”], Method -> “Queued”]

works without error.