Answers.Body: <p>You can find the id in the database in the <code>craft_assetfolders</code> table. Creating a field with <em>uploads restricted to a single folder</em> does not create an asset folder. The asset folder only gets created when you actually have an asset in that folder, so before that point there is no <code>id</code>.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-19T18:50:34.863Z
Answers.Text: Thanks for the answer Marion, it does seem there's no simple way within the CP without resorting to querying the db then. Not a problem though.
Answers.UserDisplayName: John Moylan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-18T17:49:36.543Z
Answers.LastActivityDate: 2014-07-18T17:49:36.543Z
Answers.UserDisplayName: Marion Newlevant
Answers.Body: <p>Another approach is to inspect the sidebar element in the control panel using your browser. The screenshot below shows a <em>media</em> folder (id 9) that’s nested under a parent folder (id 1)</p>
  
  <p><a href="https://i.sstatic.net/xngS3.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/xngS3.png" alt="screenshot of the CP sidebar’s folder element"></a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-22T19:03:13.577Z
Answers.LastActivityDate: 2018-03-22T19:03:13.577Z
Answers.UserDisplayName: Stephen Bowling
Answers.Body: <p>You can do it like that     </p>
  
  <pre><code>// return an associative array with the asset source handle as key
  $assetSources = craft()-&gt;assetSources-&gt;getPublicSources('handle');
  $assetSource = $assetSources['yourAssetSrcHandle'];
  $assetFolder = craft()-&gt;assets-&gt;getRootFolderBySourceId($assetSource-&gt;id);
  $assetFolder-&gt;id;
  </code></pre>
  
  <p>I also find weird that there is no direct method to get this from an asset source handle...</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-03-22T18:55:33.463Z
Answers.LastActivityDate: 2018-03-22T18:55:33.463Z
Answers.UserDisplayName: Thomas Joeisseint
Answers.Body: <p>Checkout the <a href="https://github.com/bjerenec/craftcms-blueprint/" rel="nofollow">blueprint</a> plugin. It doesn't currently do this, but it does similar things.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-07-19T18:57:17.823Z
Answers.LastActivityDate: 2014-07-19T18:57:17.823Z
Answers.UserDisplayName: Marion Newlevant
Body: <p>I'm iterating through a folder using craft.assets, to select the folder I'll use the folderId.</p>
  
  <p>What's the best way to find the folderId of a specific folder?</p>
  
  <p>The only way I've found is to go the the Asset Settings page in the CP and hovering over a folder to see the url in the status bar in my browser.</p>
  
  <p><strong>Related Problem:</strong></p>
  
  <p>I created a folder in the CP Fields page (see image) and there seems no way to get this folderId as I cannot get to it in the Asset Settings page. As I only have a small number of folders I was able to figure it but it got me wondering if I was missing the obvious somewhere?</p>
  
  <p>Thanks</p>
  
  <p>John</p>
  
  <p><img src="https://i.sstatic.net/4LdAs.png" alt="Folder added in Field page"></p>
  
Tags: <assets>
Title: Best way to find a folderId
ThreadText: # Best way to find a folderId
  
  (Asked by: username_0 on 2014-07-18)
  
  I'm iterating through a folder using craft.assets, to select the folder I'll use the folderId.
  
  What's the best way to find the folderId of a specific folder?
  
  The only way I've found is to go the the Asset Settings page in the CP and hovering over a folder to see the url in the status bar in my browser.
  
  **Related Problem:**
  
  I created a folder in the CP Fields page (see image) and there seems no way to get this folderId as I cannot get to it in the Asset Settings page. As I only have a small number of folders I was able to figure it but it got me wondering if I was missing the obvious somewhere?
  
  Thanks
  
  username_0
  
  ![Folder added in Field page](https://i.sstatic.net/4LdAs.png)
  
  **Tags:** assets
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_1 on 2014-07-18. Score: 2 | Accepted answer
  
  You can find the id in the database in the `craft_assetfolders` table. Creating a field with *uploads restricted to a single folder* does not create an asset folder. The asset folder only gets created when you actually have an asset in that folder, so before that point there is no `id`.
  
  > **Comments:**
  > **username_0**: Thanks for the answer username_1, it does seem there's no simple way within the CP without resorting to querying the db then. Not a problem though.  
  
  ---
  
  ### Answer by username_2 on 2018-03-22. Score: 2
  
  Another approach is to inspect the sidebar element in the control panel using your browser. The screenshot below shows a *media* folder (id 9) that’s nested under a parent folder (id 1)
  
  [![screenshot of the CP sidebar’s folder element](https://i.sstatic.net/xngS3.png)](https://i.sstatic.net/xngS3.png)
  
  
  ---
  
  ### Answer by username_3 on 2018-03-22. Score: 2
  
  You can do it like that
  
  ```
  // return an associative array with the asset source handle as key
  $assetSources = craft()->assetSources->getPublicSources('handle');
  $assetSource = $assetSources['yourAssetSrcHandle'];
  $assetFolder = craft()->assets->getRootFolderBySourceId($assetSource->id);
  $assetFolder->id;
  
  ```
  
  I also find weird that there is no direct method to get this from an asset source handle...
  
  
  ---
  
  ### Answer by username_1 on 2014-07-19. Score: 1
  
  Checkout the [blueprint](https://github.com/bjerenec/craftcms-blueprint/) plugin. It doesn't currently do this, but it does similar things.
  
  
  ---
  
  