getDirectory(directory)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

getDirectory(directory)

Glen MacDonald-2
Hi,
Is is possible to select a directory in a macro without bringing up a  
user dialog?  getDirectory("macros") will provide the path without  
dialog.
But, this brings up the user selection dialog:

sumacros=getDirectory("macros")+"Startup_macros";
list = getFileList(getDirectory(sumacros));

thanks,
Glen


Glen MacDonald
Core for Communication Research
Virginia Merrill Bloedel Hearing Research Center
Box 357923
University of Washington
Seattle, WA 98195-7923  USA
(206) 616-4156
[hidden email]

******************************************************************************
The box said "Requires WindowsXP or better", so I bought a Macintosh.
******************************************************************************
Reply | Threaded
Open this post in threaded view
|

Re: getDirectory(directory)

b holi
Glen,

Yes, it is possible but two corrections are needed in your code.

1. The concatenated pathname string to access a folder must include a file
separator character at the end, as below.

2. Your string assignment for 'sumacros' already uses 'getDirectory()' so
it's not needed again in your second line

This will access the folder named 'Startup_macros' with no intervening
Dialog window:
__________

sumacros=getDirectory("macros")+"Startup_macros"+File.separator;

if (File.exists(sumacros)) {
    list = getFileList(sumacros);

    for (i=0; i<list.length; i++) {
        if (endsWith(list[i],'/'))
            print(list[i]+' is a folder');
        else
            print(list[i]+' is a file');
    }
    print('');
}
else
    showMessage('The directory '+sumacros+' was not found.');
______________________

-Bruce






On Fri, Mar 20, 2009 at 5:13 PM, Glen MacDonald <[hidden email]>wrote:

> Hi,
> Is is possible to select a directory in a macro without bringing up a user
> dialog?  getDirectory("macros") will provide the path without dialog.
> But, this brings up the user selection dialog:
>
> sumacros=getDirectory("macros")+"Startup_macros";
> list = getFileList(getDirectory(sumacros));
>
> thanks,
> Glen
>
>
> Glen MacDonald
> Core for Communication Research
> Virginia Merrill Bloedel Hearing Research Center
> Box 357923
> University of Washington
> Seattle, WA 98195-7923  USA
> (206) 616-4156
> [hidden email]
>
>
> ******************************************************************************
> The box said "Requires WindowsXP or better", so I bought a Macintosh.
>
> ******************************************************************************
>