# GET DIRECTORY LIST OF ONLY .png FILES

**URL:** <https://discourse.processing.org/t/get-directory-list-of-only-png-files/1662>\
**Category:** Processing\
**Created:** [July 10, 2018, 5:52pm UTC](https://discourse.processing.org/t/get-directory-list-of-only-png-files/1662 "2018-07-10T17:52:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffmarc](https://avatars.discourse-cdn.com/v4/letter/j/82dd89/32.png) [@jeffmarc](https://discourse.processing.org/u/jeffmarc)\
**Post date:** [July 10, 2018, 5:52pm UTC](https://discourse.processing.org/t/get-directory-list-of-only-png-files/1662/1 "2018-07-10T17:52:01Z")

</div>

Found code to get listing of names in a directory.

[https://processing.org/examples/directorylist.html](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

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 10, 2018, 6:38pm UTC](https://discourse.processing.org/t/get-directory-list-of-only-png-files/1662/2 "2018-07-10T18:38:13Z")

</div>

> [@How to check if a file is exist in data folder by code?](https://discourse.processing.org/t/how-to-check-if-a-file-is-exist-in-data-folder-by-code/589):
>
> I have to check if a file is exist in data folder while the code is running. How to achieve that function?

---

<div class="post-metadata">

**Author:** ![WakeMeAtThree](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/wakemeatthree/32/38_2.png) [@WakeMeAtThree](https://discourse.processing.org/u/WakeMeAtThree)\
**Post date:** [July 10, 2018, 7:04pm UTC](https://discourse.processing.org/t/get-directory-list-of-only-png-files/1662/3 "2018-07-10T19:04:01Z")

</div>

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:

```java
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());
    }
  }
}

```
