简体   繁体   中英

BASH - file selection by multiple patterns in zenity

Im pretty new to zenity and bash. Im trying to make file selection window that will display only the ones with .ogg, .aac and .wav extension. I tried this, but it doesn't work.

option=`zenity --file-selection --file-filter=*.ogg | *.aac`

For one extension it's working as intented:

option=`zenity --file-selection --file-filter=*.ogg`

Zenity man provides information:

--file-filter=NAME | PATTERN1 PATTERN2
Sets a filename filter

I dont really understand how am I supposed to use it. Can someone show me some examples?

好的我找到了解决方案,也许有人会在将来使用它:

zenity --file-selection --file-filter=""*.ogg" "*.wav" "*.aac""

Special bash symbols | and * needs escaping (backslash) or quoting (single or double), and you have succeeded with that. With single quotes the argument is passed literally to zenity.

Repeat the --file-filter option if you want more filter choices For example, you may want two filters "All files" and "Music files" in the file selection window:

zenity --file-selection --file-filter='Music files (ogg,wav,aac) | *.ogg *.wav *.aac' --file-filter='All files | *'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM