Ajmal Sha
Ajmal Sha

Reputation: 956

Zenity command for multiple file filtering

I tried some Zenity command for file filtering in my java program.

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

and

zenity --file-selection --multiple --file-filter=*.gif *.jpeg *.jpg

But these are not worked properly . insted of giving the all filtered file it only give the first file type given in the comment ,thant means;

zenity --file-selection --multiple --file-filter=*.gif *.jpeg *.jpg 

in these, it given back only the .gif file as the output) .

Upvotes: 1

Views: 1630

Answers (2)

Julio N
Julio N

Reputation: 11

If you do:

$ zenity --file-selection \
         --file-filter='Musics | *.ogg | *.wav | *.aac'

All selected file types will be printed together. It's a mess...

If you do:

$ zenity --file-selection \
         --file-filter='*.ogg' \
         --file-filter='*.wav' \
         --file-filter='*.aac'

In the lower right corner a combo with these 3 file types should be generated where you can choose which one is printed, type by type

If I were you, I would install the YAD that is fork of zenity, but at a much more advanced stage.

Upvotes: 1

Mustafa DOGRU
Mustafa DOGRU

Reputation: 4112

Could you try something like this;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class RunBash {

    public static void main(String[] args) {
          String cmd = "zenity --file-selection --file-filter=\"\"*.gif\" \"*.jpeg\" \"*.jpg\"\"";

            try {
                Process proc = Runtime.getRuntime().exec(new String[] {"/bin/bash", "-c", cmd});
                BufferedReader read = new BufferedReader(new InputStreamReader(proc.getInputStream()));
                try {
                    proc.waitFor();
                } catch (InterruptedException e) {
                    System.out.println(e.getMessage());
                }
                while (read.ready()) {
                    System.out.println(read.readLine());
                }
            } catch (IOException e) {
                System.out.println(e.getMessage());
            }
    }
}

Upvotes: 1

Related Questions