# How to check if a file is exist in data folder by code?

**URL:** <https://discourse.processing.org/t/how-to-check-if-a-file-is-exist-in-data-folder-by-code/589>\
**Category:** Processing.py\
**Created:** [June 1, 2018, 4:03am UTC](https://discourse.processing.org/t/how-to-check-if-a-file-is-exist-in-data-folder-by-code/589 "2018-06-01T04:03:18Z")\
**Posts on this page:** 1\
**Showing post:** 7

<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:** [June 1, 2018, 6:45am UTC](https://discourse.processing.org/t/how-to-check-if-a-file-is-exist-in-data-folder-by-code/589/7 "2018-06-01T06:45:51Z")

</div>

> [@newton45](#):
>
> Or is there any function to get current processing data folder’s path?

Yes! Just pass an empty string `""` to **dataPath()**:

```auto
dataFolderPath = this.dataPath('') + '/'
print dataFolderPath

```

… or to **dataFile()**:

```auto
dir = this.dataFile('')
dataFolderPath = dir.path + '/'
print dataFolderPath

```

However, if you need all files within the sketch’s “data/” folder, like all images for example, you can use **listPaths()**, passing the “data/” folder path + a string w/ all desired “extensions=,”: 🕶

```auto
PICS_EXTS = 'extensions=,png,jpg,jpeg,gif,tif,tiff,tga,bmp,wbmp'

dir = this.dataFile('')
imagePaths, imagesFound = (), 0

if dir.isDirectory():
    imagePaths = this.listPaths(dir.path, PICS_EXTS)
    imagesFound = len(imagePaths)

printArray(imagePaths)
print 'Found %d image(s)' % imagesFound

```

---

_[View the full topic](https://discourse.processing.org/t/how-to-check-if-a-file-is-exist-in-data-folder-by-code/589)._
