# win\_find and nested loops

**URL:** <https://forum.ansible.com/t/win-find-and-nested-loops/31423>\
**Category:** AWX Project\
**Created:** [October 4, 2019, 6:23am UTC](https://forum.ansible.com/t/win-find-and-nested-loops/31423 "2019-10-04T06:23:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jeremy\_Rogers](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@Jeremy\_Rogers](https://forum.ansible.com/u/Jeremy_Rogers)\
**Post date:** [October 4, 2019, 6:23am UTC](https://forum.ansible.com/t/win-find-and-nested-loops/31423/1 "2019-10-04T06:23:07Z")

</div>

I’m attempting to write a playbook using the win\_find module. We are looking for files in a set of specific directories that are older than 30 days.

I’m able to get a list of files from the playbook, but getting all the way down to the path is escaping me. I think I have a handle on nested loops, but since these two loops are connected, I’m having a hard time putting it together.

My win\_dir task:

- name: “Finding files older than 30 days”  
win\_find:  
paths: “{{ item }}”  
age: 30d  
register: list\_30days  
loop: “{{ day30\_dir }}”

I’m just struggling to get the path from list\_30days.results with a nested loop. I can make it to “{{ item.files }}”, just can’t seem to loop over that list.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![sdmorel](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@sdmorel](https://forum.ansible.com/u/sdmorel)\
**Post date:** [October 7, 2019, 1:28pm UTC](https://forum.ansible.com/t/win-find-and-nested-loops/31423/2 "2019-10-07T13:28:44Z")

</div>

Hello,

Don’t think this is an AWX specific topic, but you can use the [json\_query](https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#json-query-filter) filter to access the path of the file.

Good luck!

---

<div class="post-metadata">

**Author:** ![Jeremy\_Rogers](https://avatars.discourse-cdn.com/v4/letter/j/a9adbd/32.png) [@Jeremy\_Rogers](https://forum.ansible.com/u/Jeremy_Rogers)\
**Post date:** [October 7, 2019, 1:30pm UTC](https://forum.ansible.com/t/win-find-and-nested-loops/31423/3 "2019-10-07T13:30:48Z")

</div>

Yeah, thought about that after I had posted it.

I did end up figuring it out by looking at the Ansible documentation on loops.

Thanks for the response.
