# Way to copy a zip file and replace folder inside it with folder on node?

**URL:** <https://discourse.chef.io/t/way-to-copy-a-zip-file-and-replace-folder-inside-it-with-folder-on-node/11571>\
**Category:** Chef Infra (archive)\
**Created:** [September 20, 2017, 9:13am UTC](https://discourse.chef.io/t/way-to-copy-a-zip-file-and-replace-folder-inside-it-with-folder-on-node/11571 "2017-09-20T09:13:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ankur760](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Ankur760](https://discourse.chef.io/u/Ankur760)\
**Post date:** [September 20, 2017, 9:13am UTC](https://discourse.chef.io/t/way-to-copy-a-zip-file-and-replace-folder-inside-it-with-folder-on-node/11571/1 "2017-09-20T09:13:36Z")

</div>

What actually i want to to copy a zip file from share directory,  
and want to unzip it and replace folders on node with folder inside zip file ?

---

<div class="post-metadata">

**Author:** ![simark](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/simark/32/2099_2.png) [@simark](https://discourse.chef.io/u/simark)\
**Post date:** [September 20, 2017, 9:43am UTC](https://discourse.chef.io/t/way-to-copy-a-zip-file-and-replace-folder-inside-it-with-folder-on-node/11571/2 "2017-09-20T09:43:17Z")

</div>

@Ankur760

If the zip file can be retrieved from URL, then I would suggest to grab the file by using the `windows_zipfile` LWRP from the `windows` cookbook. This resource would grab the file and unzip it.

> **[chef-cookbooks/windows](https://github.com/chef-cookbooks/windows#windows_zipfile)**
>
> Development repository for Chef Cookbook windows

To utilize the `windows` cookbook you need define it as a dependency in your cookbooks `metadata.rb`

If you can only get it from a share then  
Use the `remote_file` resource to grab the file that you want from the share  
[https://docs.chef.io/resource\_remote\_file.html](https://docs.chef.io/resource_remote_file.html)  
After that you can use the `windows_zipfile` resource that would point to the local zip file that was previously download by the `remote_file` resource.

The other part I do not understand exactly. You want to put in folders from a zip archive into a specified folder?  
There is no chef resource that would do that for you. You would need to pragmatically write that in for example PowerShell and use the `powershell_script` resource to execute your custom code. Please be aware that you should guarantee idempotency with the `not_if` or `ony_if` guards
