Tools: MPW
Advanced Search
Apple Developer Connection
Member Login Log In | Not a Member? Support

MPW Command Reference


GetFileName

Tool

SYNTAX

GetFileName [pathname] [-b buttonTitle]
[-c | [-d | -p | -t type | -wd] [-m message]]
[-noResolve] [-q] [-s] [-stdfile | -navsvc]

DESCRIPTION

The GetFileName tool displays a Standard File dialog in which you can select or enter a filename. After you have specified the filename in the dialog, GetFileName returns this filename as a pathname to standard output. This allows you to use the output of a dialog transaction in a script.

The dialog produced can be one of two types: The first type is the SFGetFile dialog, which allows you to click a filename. GetFileName produces this dialog by default. This dialog can also be used for selecting a directory (-d). In this case the directory is selected in the same manner as a file.

The second type of dialog is the SFPutFile dialog, which allows you to enter a filename in a text field after selecting the directory in which the file should be placed. The -p option selects this type of dialog.

Note
GetFileName supports Navigation Services dialogs, but only in the PowerPC executable version of the tool, and only if Navigation Services is available for use by the tool. The tool respects the setting of the {UseStandardFile} shell environment variable, if the variable is exported. •

INPUT

None

OUTPUT

Standard output. The GetFileName tool writes a full pathname starting at the volume root to standard output.

STATUS

The GetFileName command can return the following status codes:

0

user specified a file and no errors occurred

1

parameter or option error

2

system error

4

user canceled the standard file dialog

PARAMETERS

pathname

Sets the starting directory in the dialog to pathname. Normally GetFileName starts with the current pathname.

If you call an SFPutFile dialog (-p) and pathname includes a local filename, GetFileName uses it as the default filename. That is, it appears in the dialog's text field and is automatically returned if you do not alter it.

OPTIONS

-b buttonTitle

Renames the default button in the dialog. If you do not specify this option, Open is used in the standard SFGetFile dialog, Directory in the directory SFGetFile dialog, and Save in the standard SFPutFile dialog.

-c

Writes the current standard file pathname to standard output without displaying a dialog.

-d

Displays an SFGetFile dialog for selecting a directory.

-m message

Specifies a prompt message. This message appears below the scroll box in an SFGetFile dialog and directly above the text field in an SFPutFile dialog.

-navsvc

Forces the use of Navigation Services dialogs (if Navigation Services is available).

-noResolve

Forces the pathname of the alias file to be returned (instead of the target folder of the resolved alias) if a folder alias is selected during a -d or -wd dialog.

-p

Displays an SFPutFile dialog.

-q

Inhibits putting quotation marks around the pathname written to standard output. Pathnames are normally enclosed in quotation marks when necessary.

-s

Returns a status of 0 even if Cancel is clicked.

-stdfile

Forces the use of StandardFile dialogs.

-t type

Filters SFGetFile by allowing only files of the specified type to be selected. These files appear in boldface, while files of other types appear dim and cannot be selected.

Note that you can specify additional types (up to four) by repeating the -t type option. This option is case sensitive.

-wd

Selects a writeable directory on a nonlocked volume.

EXAMPLES

The following command line opens the text file in the {CIncludes} directory chosen in the SFGetFile dialog:

Open `GetFileName -t TEXT {CIncludes}`

The following command line displays an SFPutFile dialog with the directory set to HD:MPW and StartUp appearing in the text field.

GetFileName -p HD:MPW:StartUp

LIMITATIONS

The resulting pathname cannot be longer than 255 characters.

SEE ALSO

Information about the Standard File Package in Inside Macintosh

 
 


Last Updated July 2000