Answers.Body: <p>Seems doable with a custom <a href="https://pluginfactory.io" rel="nofollow noreferrer">plugin</a>.</p>
  
  <p>The pseudo-code would be something like:</p>
  
  <ol>
  <li>Use <a href="https://craftcms.com/classreference/services/AssetsService" rel="nofollow noreferrer">AssetsService</a> to grab all of the files for the source.</li>
  <li>Loop through the files and parse the parent folder paths.</li>
  <li>Based on the subfolder for the asset, check if an existing tag already exists with the <a href="https://craftcms.com/classreference/services/TagsService" rel="nofollow noreferrer">TagsService</a>.</li>
  <li>If 3 is true, assign that tag's value to a tag field on the Asset.</li>
  <li>If 3 is false, create the tag using the TagsService, then assign that tag's value to a tag field on the Asset.</li>
  </ol>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-02-14T20:10:41.417Z
Answers.LastActivityDate: 2017-02-14T20:10:41.417Z
Answers.UserDisplayName: Brad Bell
Body: <p>I'm building a project with a lot of photo assets organized into sub directories of the main photos asset source. I'm trying to add tags to these assets so they are searchable when I try to use them in my entries.</p>
  
  <p>With native features of Craft, this process seems to be very manual, I just have to click on each of these asset files and add the tags that I want.</p>
  
  <p>Is there a way, either using a plugin or make a MySQL query, to bulk add tags to all the asset files under a certain sub directory?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-10T22:01:29.550Z
Comments.Text: Are the tags based on the subfolder name or something?  Or are they going to be more dynamic regardless of what folder they live in?
Comments.UserDisplayName: Brad Bell
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-02-14T00:12:43.017Z
Comments.Text: The tags are supposed to be the same as the subfolder names.
Comments.UserDisplayName: ChaiTea
Tags: <assets><plugins><tags><mysql><subfolder>
Title: Tagging all assets in a sub directory
ThreadText: # Tagging all assets in a sub directory
  
  (Asked by: username_0 on 2017-02-10)
  
  I'm building a project with a lot of photo assets organized into sub directories of the main photos asset source. I'm trying to add tags to these assets so they are searchable when I try to use them in my entries.
  
  With native features of Craft, this process seems to be very manual, I just have to click on each of these asset files and add the tags that I want.
  
  Is there a way, either using a plugin or make a MySQL query, to bulk add tags to all the asset files under a certain sub directory?
  
  **Tags:** assets, plugins, tags, mysql, subfolder
  
  > **Comments:**
  > **username_1**: Are the tags based on the subfolder name or something?  Or are they going to be more dynamic regardless of what folder they live in?  
  > **username_0**: The tags are supposed to be the same as the subfolder names.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-02-14. Score: 1
  
  Seems doable with a custom [plugin](https://pluginfactory.io).
  
  The pseudo-code would be something like:
  
  1. Use [AssetsService](https://craftcms.com/classreference/services/AssetsService) to grab all of the files for the source.
  2. Loop through the files and parse the parent folder paths.
  3. Based on the subfolder for the asset, check if an existing tag already exists with the [TagsService](https://craftcms.com/classreference/services/TagsService).
  4. If 3 is true, assign that tag's value to a tag field on the Asset.
  5. If 3 is false, create the tag using the TagsService, then assign that tag's value to a tag field on the Asset.
  
  
  ---
  
  