MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

ActionMenu with directories

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105926] ActionMenu with directories
  • From: "Kevin J. McCann" <kjm at KevinMcCann.com>
  • Date: Sat, 26 Dec 2009 19:07:32 -0500 (EST)

I would like to write a short script to create an action menu from which 
I can choose a directory. I have a data directory (Windows) whose only 
members are directories (each named by the date the data were taken). I 
would like to create an action menu that lists these directories and 
then does a SetDirectory to the chosen one. Here is what I have tried:

dirs=FileNames[];
numDirs=Length[dirs];
menu={};
For[k=1,k<=numDirs,
AppendTo[menu,RuleDelayed[ToString[dirs[[k]]],SetDirectory[dirs[[k]]]]];
k=k+1;
]

ActionMenu["Choose Directory",menu]

It creates the menu, but it doesn't convert the SetDirectory correctly.

Any ideas?

Also, is there a way to tell if a FileNames output is a directory or file?

Thanks,

Kevin


  • Prev by Date: Taylor expansion of Jacobi's elliptic functions
  • Next by Date: StringMatchQ and non-ASCII characters
  • Previous by thread: Re: Taylor expansion of Jacobi's elliptic functions
  • Next by thread: Re: ActionMenu with directories