Search code examples
dialogzenity

Bash script use multiple fselect dialog


I wrote a shell script to enable big file transfers to my VPS. So, something similar to MyAirbridge or WeTransfer, but from the cli.

When I use Zenity, it is possible to present a file selection dialog (GTK+) that enables to select multiple files. However, users of the script are forced to use a graphical environment. I want to write the script for platforms without a graphical environment, so pure shell orientated. A solution to select files without a graphical environment is "Dialog". With Dialog however, it seems to be impossible to select multiple files at once.

With Zenity:

files=$(zenity --file-selection --multiple --separator=$'\n' --file-filter='*.*')

With dialog:

files=$(dialog --stdout --title "Choose a file" --fselect $HOME/ 14 48)

Anyone of you can teach me a workaround for this issue?

Kind regards, Kees


Solution

  • The file-selection dialog is useful for navigating around the directory tree and finding a specific file. It can also select a directory. You could modify the script to

    • select a directory of interest
    • display a list of all files in the directory as a checkbox widget

    (It would be not as nice as a single widget, but would work).