Use the --file-selection option. File Selection Dialogue

Use the --file-selection option to create a file selection dialog. Zenity returns the selected files or directories to standard output. The default mode of the file selection dialog is open.

The file selection dialogue supports the following options:

<cmd>--filename</cmd>=<var>filename</var>

Specifies the file or directory that is selected in the file selection dialogue when the dialogue is first shown.

<cmd>--multiple</cmd>

Allows the selection of multiple filenames in the file selection dialogue.

<cmd>--directory</cmd>

Allows only selection of directories in the file selection dialogue.

<cmd>--save</cmd>

Set the file selection dialogue into save mode.

<cmd>--separator</cmd>=<var>separator</var>

Specifies the string that is used to divide the returned list of filenames.

The following example script shows how to create a file selection dialog:

#!/bin/sh FILE=`zenity --file-selection --title="Select a File"` case $? in 0) echo "\"$FILE\" selected.";; 1) echo "No file selected.";; -1) echo "An unexpected error has occurred.";; esac
File Selection Dialogue Example Zenity file selection dialog example