Answers.Body: <p>Yes, you'd need to <a href="https://nystudio107.com/blog/so-you-wanna-make-a-craft-3-plugin" rel="nofollow noreferrer">write a plugin</a> to do this... or you could <a href="https://nystudio107.com/blog/enhancing-a-craft-cms-3-website-with-a-custom-module" rel="nofollow noreferrer">write a module</a>. There are some plugins that may already do what you want tho: <a href="https://plugins.craftcms.com/squeeze" rel="nofollow noreferrer">Squeeze</a> / <a href="https://plugins.craftcms.com/compress" rel="nofollow noreferrer">Compress</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-20T17:50:04.000Z
Answers.Text: Thanks for the answer.  I'm already using Squeeze, it only seems to zip files, not a folder.
Answers.UserDisplayName: JJefferyDev
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-22T10:51:42.423Z
Answers.Text: @JJefferyDev you can combine multiple files in one download so you should be able to retrieve a complete folder with it.
Answers.UserDisplayName: Oli
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-18T02:15:35.703Z
Answers.LastActivityDate: 2020-01-18T02:15:35.703Z
Answers.UserDisplayName: andrew.welch
Body: <p>I've searched everywhere but can't seem to get a straight answer.  I want to write a php script to zip and download an entire subfolder in my assets directory.  The subfolders are named based on a variable.  Where do I write this php code?  Must I write a custom plugin for something so simple?</p>
  
Tags: <plugin-development><craft3><plugins><php>
Title: How can I write a PHP script to zip and download an Assets subfolder?
ThreadText: # How can I write a PHP script to zip and download an Assets subfolder?
  
  (Asked by: username_0 on 2020-01-18)
  
  I've searched everywhere but can't seem to get a straight answer. I want to write a php script to zip and download an entire subfolder in my assets directory. The subfolders are named based on a variable. Where do I write this php code? Must I write a custom plugin for something so simple?
  
  **Tags:** plugin-development, craft3, plugins, php
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2020-01-18. Score: 2
  
  Yes, you'd need to [write a plugin](https://nystudio107.com/blog/so-you-wanna-make-a-craft-3-plugin) to do this... or you could [write a module](https://nystudio107.com/blog/enhancing-a-craft-cms-3-website-with-a-custom-module). There are some plugins that may already do what you want tho: [Squeeze](https://plugins.craftcms.com/squeeze) / [Compress](https://plugins.craftcms.com/compress)
  
  > **Comments:**
  > **username_0**: Thanks for the answer.  I'm already using Squeeze, it only seems to zip files, not a folder.  
  > **username_2**: @username_0 you can combine multiple files in one download so you should be able to retrieve a complete folder with it.  
  
  ---
  
  