# Check file exists and skip task in next run playbooks

**URL:** <https://forum.ansible.com/t/check-file-exists-and-skip-task-in-next-run-playbooks/35451>\
**Category:** Ansible Project\
**Created:** [July 2, 2021, 8:34am UTC](https://forum.ansible.com/t/check-file-exists-and-skip-task-in-next-run-playbooks/35451 "2021-07-02T08:34:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ti\_n\_Nguy\_n](https://avatars.discourse-cdn.com/v4/letter/t/8dc957/32.png) [@Ti\_n\_Nguy\_n](https://forum.ansible.com/u/Ti_n_Nguy_n)\
**Post date:** [July 2, 2021, 8:34am UTC](https://forum.ansible.com/t/check-file-exists-and-skip-task-in-next-run-playbooks/35451/1 "2021-07-02T08:34:35Z")

</div>

I write my playbook

- name: stat /opt/zookeeper-3.4.14/\*  
stat:  
path: “/opt/zookeeper-3.4.14”  
register: zoo
- name: mv opt/zookeeper-3.4.14 /opt/zookeeper  
shell: mv /opt/zookeeper-3.4.14/\* /opt/zookeeper  
when: zoo.stat.exists

I run the command for the first time, every thing is ok.  
But from the 2nd run. I get the following error

 ![Capture.PNG](https://us1.discourse-cdn.com/ansible/original/2X/c/cee3c450bcc4ba48523c7ad0cd2d5a60ec759581.png)  
Is there a way to run this task on the 1st run. Can I skip it on the 2nd run?  
Thanks!
