# list all files in directory and copy all content.

**URL:** <https://forum.ansible.com/t/list-all-files-in-directory-and-copy-all-content/35522>\
**Category:** Ansible Project\
**Created:** [July 20, 2021, 1:42am UTC](https://forum.ansible.com/t/list-all-files-in-directory-and-copy-all-content/35522 "2021-07-20T01:42:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vincent\_Nambatac](https://avatars.discourse-cdn.com/v4/letter/v/d07c76/32.png) [@Vincent\_Nambatac](https://forum.ansible.com/u/Vincent_Nambatac)\
**Post date:** [July 20, 2021, 1:42am UTC](https://forum.ansible.com/t/list-all-files-in-directory-and-copy-all-content/35522/1 "2021-07-20T01:42:49Z")

</div>

Hi there , I want to ask what approach I will do If I want to copy all content in an unzip files. I unzip the files and list all directories. the problem is I want to copy all files inside the directory but only 1 content being copied. Can somebody how to it. Here is my code.

- name: "Unzip zookeeper package {{ zookeeper\_installation\_package }} "  
unarchive:  
src: “{{ zookeeper\_install\_package\_host\_folder }}/{{ zookeeper\_installation\_package }}”  
dest: “{{ zookeeper\_install\_package\_host\_folder }}”  
list\_files: yes  
remote\_src: yes  
register: unarchived\_list

- name: Removing {{ zookeeper\_install\_package\_host\_folder }}/{{ zookeeper\_installation\_package }}  
file:  
path: “{{ zookeeper\_install\_package\_host\_folder }}/{{ zookeeper\_installation\_package }}”  
state: absent

- name: Create symbolic link {{ zookeeper\_sym\_link }} for {{zookeeper\_install\_package\_host\_folder}}/{{ unarchived\_list.files[0] }}  
file:  
src: “{{zookeeper\_install\_package\_host\_folder}}/{{ unarchived\_list.files[0] }}”  
dest: “/opt/zookeeper”  
state: link

— in the Create symbolic link Task I want to copy all content in my unzip file which is zookeeper.tar and make a symbolic link with it using all the content to /opt/zookeeper directory.

 ![Screenshot from 2021-07-20 09-40-10.png](https://us1.discourse-cdn.com/ansible/original/2X/4/40b15a3bd3acf0ce6aabc56294d2ca403a14a2f6.png)

In this case , only docs directory being copied . instead all the content .

Best regards,  
Vincent

---

<div class="post-metadata">

**Author:** ![Vincent\_Nambatac](https://avatars.discourse-cdn.com/v4/letter/v/d07c76/32.png) [@Vincent\_Nambatac](https://forum.ansible.com/u/Vincent_Nambatac)\
**Post date:** [July 20, 2021, 1:49am UTC](https://forum.ansible.com/t/list-all-files-in-directory-and-copy-all-content/35522/2 "2021-07-20T01:49:06Z")

</div>

I suspect what would be the right value in this unarchived\_list.files[0] to input to copy all directories. When I tried another number like 1,2,3 only those another directories there are being copied .
