# How to specify foldername with wildcard inside a jinja template

**URL:** <https://forum.ansible.com/t/how-to-specify-foldername-with-wildcard-inside-a-jinja-template/32414>\
**Category:** Ansible Project\
**Created:** [March 7, 2020, 5:27am UTC](https://forum.ansible.com/t/how-to-specify-foldername-with-wildcard-inside-a-jinja-template/32414 "2020-03-07T05:27:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shifa\_Shaikh](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Shifa\_Shaikh](https://forum.ansible.com/u/Shifa_Shaikh)\
**Post date:** [March 7, 2020, 5:27am UTC](https://forum.ansible.com/t/how-to-specify-foldername-with-wildcard-inside-a-jinja-template/32414/1 "2020-03-07T05:27:31Z")

</div>

I wish to check using if condition inside a jinja template where any of the folders starting with the name “dump\_” has any file starting with the name bad

For for single folder the below jinja template works as suggested by an expert on this forum.

`{% if lookup('fileglob', playbook_dir + '/' + 'dump_' + item + '/' + 'bad*.txt') %}`

I understand that fileglob supports wildcards only on files and not on folders.

The below fails when wildcard is applied to a folder.

`{% if lookup('fileglob', playbook_dir + '/' + 'dump_*' + '/' + 'bad*.txt') %}`

Any solution to this problem please inside a jinja template?

---

<div class="post-metadata">

**Author:** ![Dick\_Visser](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@Dick\_Visser](https://forum.ansible.com/u/Dick_Visser)\
**Post date:** [March 7, 2020, 5:34pm UTC](https://forum.ansible.com/t/how-to-specify-foldername-with-wildcard-inside-a-jinja-template/32414/2 "2020-03-07T17:34:27Z")

</div>

Try the 'lines' lookup with a custom 'find' shell command ?
