<?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 Re: Use da.Walk with os.path.getfilesize? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/use-da-walk-with-os-path-getfilesize/m-p/375077#M29642</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No problem.&amp;nbsp; Whether my response or someone else's, please close out your questions by marking a "Correct" answer when you no longer have an issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 11 May 2015 16:52:14 GMT</pubDate>
    <dc:creator>JoshuaBixby</dc:creator>
    <dc:date>2015-05-11T16:52:14Z</dc:date>
    <item>
      <title>Use da.Walk with os.path.getfilesize?</title>
      <link>https://community.esri.com/t5/python-questions/use-da-walk-with-os-path-getfilesize/m-p/375073#M29638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've been tasked with providing a csv of all my file geo dbs and their file sizes. Suggestions, please?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 21:18:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-da-walk-with-os-path-getfilesize/m-p/375073#M29638</guid>
      <dc:creator>AlixBakke_SNC</dc:creator>
      <dc:date>2015-05-08T21:18:59Z</dc:date>
    </item>
    <item>
      <title>Re: Use da.Walk with os.path.getfilesize?</title>
      <link>https://community.esri.com/t5/python-questions/use-da-walk-with-os-path-getfilesize/m-p/375074#M29639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you only looking at file geodatabases? Are they all in the same folder? Please describe your situation with more detail.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 08 May 2015 23:35:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-da-walk-with-os-path-getfilesize/m-p/375074#M29639</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2015-05-08T23:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Use da.Walk with os.path.getfilesize?</title>
      <link>https://community.esri.com/t5/python-questions/use-da-walk-with-os-path-getfilesize/m-p/375075#M29640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In this situation, &lt;A href="http://desktop.arcgis.com/en/desktop/latest/analyze/arcpy-data-access/walk.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;arcpy.da.Walk&lt;/SPAN&gt; &lt;/A&gt;doesn't get you anything over &lt;A href="https://docs.python.org/2/library/os.html#files-and-directories" rel="nofollow noopener noreferrer" target="_blank"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;os.walk&lt;/SPAN&gt; &lt;/A&gt;because&lt;SPAN style="font-family: courier new,courier;"&gt; arcpy.da.Walk&lt;/SPAN&gt; is focused on the contents of geospatial data stores (feature classes, raster catalogs, tables, etc...) and not the data stores themselves (file geodatabases, folders, enterprise geodatabases, etc...).&amp;nbsp; &lt;SPAN style="font-family: courier new,courier;"&gt;arcpy.da.Walk&lt;/SPAN&gt; can do the job, it just does it slower because of the extra overhead from enumerating geospatial data within the data stores.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Since you primarily seem interested in only the size of the file geodatabases and not the specifics of what is inside them, I recommend using straight &lt;SPAN style="font-family: courier new,courier;"&gt;os.walk&lt;/SPAN&gt; to find the file geodatabases and determine their sizes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import os

def get_size(start_path = '.'):
&amp;nbsp;&amp;nbsp;&amp;nbsp; total_size = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; for dirpath, dirnames, filenames in os.walk(start_path):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for f in filenames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fp = os.path.join(dirpath, f)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; total_size += os.path.getsize(fp)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return total_size

output = #output file
path = #root/parent directory to start recursive search

with open(output, 'w') as f:
&amp;nbsp;&amp;nbsp;&amp;nbsp; for dirpath, dirnames, filenames in os.walk(path):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for dirname in dirnames:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if dirname.endswith('.gdb'):
&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; gdb = os.path.join(dirpath, dirname)
&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; size = get_size(gdb)
&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; f.write("{},{}\n".format(gdb, size))&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;SPAN style="font-family: courier new,courier;"&gt;get_size&lt;/SPAN&gt; function code came from the accepted answer by &lt;A href="http://stackoverflow.com/users/24718/monkut" rel="nofollow noopener noreferrer" target="_blank"&gt;monkut &lt;/A&gt;to the following Stackoverflow post:&amp;nbsp; &lt;A href="http://stackoverflow.com/questions/1392413/calculating-a-directory-size-using-python" rel="nofollow noopener noreferrer" target="_blank"&gt;Calculating a directory size using Python?&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 17:21:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-da-walk-with-os-path-getfilesize/m-p/375075#M29640</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T17:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Use da.Walk with os.path.getfilesize?</title>
      <link>https://community.esri.com/t5/python-questions/use-da-walk-with-os-path-getfilesize/m-p/375076#M29641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Super helpful, thank you VERY much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 May 2015 16:05:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-da-walk-with-os-path-getfilesize/m-p/375076#M29641</guid>
      <dc:creator>AlixBakke_SNC</dc:creator>
      <dc:date>2015-05-11T16:05:23Z</dc:date>
    </item>
    <item>
      <title>Re: Use da.Walk with os.path.getfilesize?</title>
      <link>https://community.esri.com/t5/python-questions/use-da-walk-with-os-path-getfilesize/m-p/375077#M29642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No problem.&amp;nbsp; Whether my response or someone else's, please close out your questions by marking a "Correct" answer when you no longer have an issue.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 11 May 2015 16:52:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/use-da-walk-with-os-path-getfilesize/m-p/375077#M29642</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2015-05-11T16:52:14Z</dc:date>
    </item>
  </channel>
</rss>

