<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Getting all folders from the GIS object in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/getting-all-folders-from-the-gis-object/m-p/1242711#M8191</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am busy experimenting with cloning content from ArcGIS Online to Portal, using this very useful page:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/guide/cloning-content/#the-cloning-process" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/python/guide/cloning-content/#the-cloning-process&lt;/A&gt;&lt;/P&gt;&lt;P&gt;However, I am running into a piec of caode that does not work, it's the piece where hosted feature layers are cloned into a recreated folder structure, where it's the last part, recreating the folder structure, that's giving me problems. More specifically, it is this piece of code:&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;for&lt;/SPAN&gt;&lt;SPAN&gt; hfs &lt;/SPAN&gt;&lt;SPAN class=""&gt;in&lt;/SPAN&gt;&lt;SPAN&gt; hosted_fsvc: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; try&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if&lt;/SPAN&gt;&lt;SPAN&gt; hfs.ownerFolder: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; folder = &lt;/SPAN&gt;&lt;SPAN class=""&gt;next&lt;/SPAN&gt;&lt;SPAN&gt;((f[&lt;/SPAN&gt;&lt;SPAN class=""&gt;'title'&lt;/SPAN&gt;&lt;SPAN&gt;] &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for&lt;/SPAN&gt;&lt;SPAN&gt; f &lt;/SPAN&gt;&lt;SPAN class=""&gt;in&lt;/SPAN&gt;&lt;SPAN&gt; source.users.me.folders &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if&lt;/SPAN&gt;&lt;SPAN&gt; f[&lt;/SPAN&gt;&lt;SPAN class=""&gt;'id'&lt;/SPAN&gt;&lt;SPAN&gt;] == hfs.ownerFolder))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I suppose this code should loop throught all folders, for every hosted feature layer, and find the one where the layer resides. However, source.users.me.folders will only find the folders that my admin user is the owner (or creator?) of.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So the question is, how would I loopt through ALL folders?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Joris Frenkel&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Dec 2022 16:05:32 GMT</pubDate>
    <dc:creator>jorisfrenkel</dc:creator>
    <dc:date>2022-12-20T16:05:32Z</dc:date>
    <item>
      <title>Getting all folders from the GIS object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/getting-all-folders-from-the-gis-object/m-p/1242711#M8191</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am busy experimenting with cloning content from ArcGIS Online to Portal, using this very useful page:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/guide/cloning-content/#the-cloning-process" target="_blank" rel="noopener"&gt;https://developers.arcgis.com/python/guide/cloning-content/#the-cloning-process&lt;/A&gt;&lt;/P&gt;&lt;P&gt;However, I am running into a piec of caode that does not work, it's the piece where hosted feature layers are cloned into a recreated folder structure, where it's the last part, recreating the folder structure, that's giving me problems. More specifically, it is this piece of code:&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;for&lt;/SPAN&gt;&lt;SPAN&gt; hfs &lt;/SPAN&gt;&lt;SPAN class=""&gt;in&lt;/SPAN&gt;&lt;SPAN&gt; hosted_fsvc: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; try&lt;/SPAN&gt;&lt;SPAN&gt;: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if&lt;/SPAN&gt;&lt;SPAN&gt; hfs.ownerFolder: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; folder = &lt;/SPAN&gt;&lt;SPAN class=""&gt;next&lt;/SPAN&gt;&lt;SPAN&gt;((f[&lt;/SPAN&gt;&lt;SPAN class=""&gt;'title'&lt;/SPAN&gt;&lt;SPAN&gt;] &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for&lt;/SPAN&gt;&lt;SPAN&gt; f &lt;/SPAN&gt;&lt;SPAN class=""&gt;in&lt;/SPAN&gt;&lt;SPAN&gt; source.users.me.folders &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if&lt;/SPAN&gt;&lt;SPAN&gt; f[&lt;/SPAN&gt;&lt;SPAN class=""&gt;'id'&lt;/SPAN&gt;&lt;SPAN&gt;] == hfs.ownerFolder))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I suppose this code should loop throught all folders, for every hosted feature layer, and find the one where the layer resides. However, source.users.me.folders will only find the folders that my admin user is the owner (or creator?) of.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So the question is, how would I loopt through ALL folders?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Joris Frenkel&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 16:05:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/getting-all-folders-from-the-gis-object/m-p/1242711#M8191</guid>
      <dc:creator>jorisfrenkel</dc:creator>
      <dc:date>2022-12-20T16:05:32Z</dc:date>
    </item>
    <item>
      <title>Re: Getting all folders from the GIS object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/getting-all-folders-from-the-gis-object/m-p/1248116#M8272</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/6070"&gt;@jorisfrenkel&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can loop through users and their folders using the below snippet, and access a list of feature services within each folder. Just extend the number of max users to cover the amount of usernames necessary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis import GIS

gis = GIS("home")

users = gis.users.search(max_users=10)

for user in users:
    print(user)
    folders = user.folders
    for folder in folders:
        folder_name = folder["title"]
        feature_services = [item for item in user.items(folder_name) if item.type == "Feature Service"]
        print(folder_name)
        for fs in feature_services:
            print("\t", fs.title)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2023 17:01:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/getting-all-folders-from-the-gis-object/m-p/1248116#M8272</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2023-01-13T17:01:09Z</dc:date>
    </item>
    <item>
      <title>Re: Getting all folders from the GIS object</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/getting-all-folders-from-the-gis-object/m-p/1248607#M8276</link>
      <description>&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;I am currently busy with other things, but I will look into it when I have the time.&lt;/P&gt;&lt;P&gt;Joris&lt;/P&gt;</description>
      <pubDate>Tue, 17 Jan 2023 09:58:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/getting-all-folders-from-the-gis-object/m-p/1248607#M8276</guid>
      <dc:creator>jorisfrenkel</dc:creator>
      <dc:date>2023-01-17T09:58:55Z</dc:date>
    </item>
  </channel>
</rss>

