GET DIRECTORY LIST OF ONLY .png FILES

Found code to get listing of names in a directory.

https://processing.org/examples/directorylist.html

but when i set path to “c:/*.png” i get null error
otherwise i can list all the files in “c:/”

asterisk works for searches in windows so it shoudl be supported at the command line level right?

Or is it not supported in the fucnctions somehow?
Thanks

Hi jeff!
I’m not sure if there is some file method with a wildcard character, but another way to solve your issue is to check if a string ends with the extension characters you’re looking for using the String.endsWith("") method. Here’s an example:

String yourPath = "C:/";
File someFolder = new File(yourPath);
File[] someFolderList = someFolder.listFiles();

for (File someFile : someFolderList) {
  // Check if it's a file or not
  if (someFile.isFile()) {
    // Check if string ends with extension
    if (someFile.getName().endsWith(".png")) {
      println(someFile.getName());
    }
  }
}