# Getting list of filenames in a folder

**URL:** <https://discourse.processing.org/t/getting-list-of-filenames-in-a-folder/17747>\
**Category:** Processing.py\
**Created:** [February 11, 2020, 7:19pm UTC](https://discourse.processing.org/t/getting-list-of-filenames-in-a-folder/17747 "2020-02-11T19:19:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cupofcalculus](https://avatars.discourse-cdn.com/v4/letter/c/5f9b8f/32.png) [@cupofcalculus](https://discourse.processing.org/u/cupofcalculus)\
**Post date:** [February 11, 2020, 7:19pm UTC](https://discourse.processing.org/t/getting-list-of-filenames-in-a-folder/17747/1 "2020-02-11T19:19:45Z")

</div>

I’m trying to write the Python equivalent of Java’s:

`fileList = dataFile("").listFiles();`

I’m not seeing a `listFiles()` in the Python reference. Am I missing it, or a work-around?

---

<div class="post-metadata">

**Author:** ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)\
**Post date:** [February 11, 2020, 7:21pm UTC](https://discourse.processing.org/t/getting-list-of-filenames-in-a-folder/17747/2 "2020-02-11T19:21:36Z")

</div>

[https://processing.org/examples/directorylist.html](https://processing.org/examples/directorylist.html)

---

<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:** [February 11, 2020, 7:24pm UTC](https://discourse.processing.org/t/getting-list-of-filenames-in-a-folder/17747/3 "2020-02-11T19:24:19Z")

</div>

Use global variable _this_ in order to access any PApplet member:  
That is, replace `dataFile('')` w/ `this.dataFile('')`

> [@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/6):
>
> f = this.dataFile('DoIExist.txt') filePath, exist = f.path, f.isFile() print filePath, exist

---

<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:** [February 11, 2020, 7:54pm UTC](https://discourse.processing.org/t/getting-list-of-filenames-in-a-folder/17747/4 "2020-02-11T19:54:11Z")

</div>

Alternatively, if a [PApplet](http://processing.github.io/processing-javadocs/core/processing/core/PApplet.html) member happens to be [`static`](https://processing.org/reference/static.html), variable _this_ can be replaced w/ _PApplet_: 🤓

1. `rnd = round(random(width))` -\> Python’s builtin version.
2. `rnd = this.round(random(width))` -\> PApplet version.
3. `rnd = PApplet.round(random(width))` -\> PApplet version too.
