# ansible find with\_items register results

**URL:** <https://forum.ansible.com/t/ansible-find-with-items-register-results/30916>\
**Category:** Ansible Project\
**Created:** [July 31, 2019, 12:46pm UTC](https://forum.ansible.com/t/ansible-find-with-items-register-results/30916 "2019-07-31T12:46:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adam](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@Adam](https://forum.ansible.com/u/Adam)\
**Post date:** [July 31, 2019, 12:46pm UTC](https://forum.ansible.com/t/ansible-find-with-items-register-results/30916/1 "2019-07-31T12:46:20Z")

</div>

I’m documenting this here for posterity because I’ve been struggling with a solution off & on for months. Of course, the solution was staring me in the face the whole time, but I couldn’t see it.

When using with\_items/loop with one task, and then looping over the results in a second task, the syntax is a little bit funky.

```auto
- name: get files to remove for uninstall
  find:
    paths: "{{item}}"
    patterns: ".*"
    use_regex: True
    file_type: directory
  register: output
  with_items:
    - "{{paths}}"

- name: debug
  debug:
    var: output

- name: debug loop
  debug:
    var: item.1.path
  with_subelements:
    - "{{output.results}}"
    - files

- name: uninstall app
  file:
    state: absent
    path: "{{item.1.path}}"
  with_subelements:
    - "{{output.results}}"
    - files
  when: output is defined

```

```auto

```

```auto
There are probably multiple ways to do this (feel free to share your own in reply.. there may be a simpler way than my own), but the way I found that works is to use with_subelements on the subsequent tasks. I hope this helps someone else out there that struggles with this. 

```
