Answers.Body: <p>Not a complete answer, but in your example <code>image</code> if going to be an instance of <a href="https://craftcms.com/classreference/models/AssetFileModel" rel="nofollow noreferrer">AssetFileModel</a>.</p>
  
  <p><code>AssetFileModel</code> has a <a href="https://craftcms.com/classreference/models/AssetFileModel#getFolder-detail" rel="nofollow noreferrer">getFolder</a> method that returns an instance of <a href="https://craftcms.com/classreference/models/AssetFolderModel" rel="nofollow noreferrer">AssetFolderModel</a>.</p>
  
  <p><code>AssetFolderModel</code> has a <a href="https://craftcms.com/classreference/models/AssetFolderModel#getChildren-detail" rel="nofollow noreferrer">getChildren</a> method you could loop through to get all of the subfolders for the given folder.</p>
  
  <p>Depending on how numerous your file/folder structure is, though, it might be more efficient to do this from PHP in a custom plugin rather than to do it from Twig.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-30T05:37:40.463Z
Answers.Text: Thanks, this gets it done. Is there a way to call a folder and get the children directly without starting from an image? I'm currently putting a tiny image that never gets displayed in the target folder for now in order to make that call.
Answers.UserDisplayName: Ryan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-30T21:40:47.987Z
Answers.Text: `craft.assets.folderId(1).find()` will give an array of AssetFileModels for every image in that folder.
Answers.UserDisplayName: Brad Bell
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-06-28T00:49:37.623Z
Answers.LastActivityDate: 2017-06-28T06:53:26.163Z
Answers.LastEditDate: 2017-06-28T06:53:26.163Z
Answers.UserDisplayName: Brad Bell
Body: <p>Is it possible to list subfolders from a specific folder?</p>
  
  <p>Context: 
  I'm printing out hundreds of icons which are maintained by moving a directory structure directly over to my public assets folder. Currently, I grab and list all icons by looking at the parent folder for icons:</p>
  
  <pre><code>{% for image in craft.assets.source('iconLibrary').limit(null) %}
     &lt;li&gt;...&lt;/li&gt;
  {% endfor %}
  </code></pre>
  
  <p>I'd like to call and list them by their individual folder names though. Is there a way to take a specific folder and return a list of subfolders?</p>
  
  <p><strong>Update:</strong>
  Brad's solution works! Though it's somewhat awkward having to call an image first to start at AssetFileModel. Hopefully this can be optimized as I'm running through a loop like
   the one above for each child folder now— </p>
  
  <pre><code>&lt;!--find image in parent icon folder to access folder via AssetFileModel.--&gt;
  {% for image in craft.assets.id('9328') %} 
     &lt;!-- get children of that asset's folder --&gt;
     {% for subfolder in image.folder.getChildren() %} //
        {{ subfolder }}   //prints each child folder name
     {% endfor %}
  {% endfor %}
  </code></pre>
  
Tags: <assets><assetfilemodel><subfolder>
Title: List subfolders of a specific asset folder
ThreadText: # List subfolders of a specific asset folder
  
  (Asked by: username_0 on 2017-06-27)
  
  Is it possible to list subfolders from a specific folder?
  
  Context:
  I'm printing out hundreds of icons which are maintained by moving a directory structure directly over to my public assets folder. Currently, I grab and list all icons by looking at the parent folder for icons:
  
  ```
  {% for image in craft.assets.source('iconLibrary').limit(null) %}
     <li>...</li>
  {% endfor %}
  
  ```
  
  I'd like to call and list them by their individual folder names though. Is there a way to take a specific folder and return a list of subfolders?
  
  **Update:**
  username_1's solution works! Though it's somewhat awkward having to call an image first to start at AssetFileModel. Hopefully this can be optimized as I'm running through a loop like
  the one above for each child folder now—
  
  ```
  <!--find image in parent icon folder to access folder via AssetFileModel.-->
  {% for image in craft.assets.id('9328') %} 
     <!-- get children of that asset's folder -->
     {% for subfolder in image.folder.getChildren() %} //
        {{ subfolder }}   //prints each child folder name
     {% endfor %}
  {% endfor %}
  
  ```
  
  **Tags:** assets, assetfilemodel, subfolder
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-06-28. Score: 1
  
  Not a complete answer, but in your example `image` if going to be an instance of [AssetFileModel](https://craftcms.com/classreference/models/AssetFileModel).
  
  `AssetFileModel` has a [getFolder](https://craftcms.com/classreference/models/AssetFileModel#getFolder-detail) method that returns an instance of [AssetFolderModel](https://craftcms.com/classreference/models/AssetFolderModel).
  
  `AssetFolderModel` has a [getChildren](https://craftcms.com/classreference/models/AssetFolderModel#getChildren-detail) method you could loop through to get all of the subfolders for the given folder.
  
  Depending on how numerous your file/folder structure is, though, it might be more efficient to do this from PHP in a custom plugin rather than to do it from Twig.
  
  > **Comments:**
  > **username_0**: Thanks, this gets it done. Is there a way to call a folder and get the children directly without starting from an image? I'm currently putting a tiny image that never gets displayed in the target folder for now in order to make that call.  
  > **username_1**: `craft.assets.folderId(1).find()` will give an array of AssetFileModels for every image in that folder.  
  
  ---
  
  