Function Repository Resource:

DirectorySize

Source Notebook

Find the total size of a directory

Contributed by: Arnoud Buzing

ResourceFunction["DirectorySize"][]

returns the byte count for the current directory as a quantity.

ResourceFunction["DirectorySize"][dir]

returns the byte count for dir as a quantity.

Details and Options

The total includes the content of all subdirectories.

Examples

Basic Examples (2) 

Find the size of the Wolfram System installation directory:

In[1]:=
ResourceFunction["DirectorySize"][$InstallationDirectory]
Out[1]=

Change the directory to the Wolfram System installation directory:

In[2]:=
SetDirectory[$InstallationDirectory]
Out[2]=

The current directory is now the installation directory:

In[3]:=
Directory[]
Out[3]=

DirectorySize with no arguments works on the current directory:

In[4]:=
ResourceFunction["DirectorySize"][]
Out[4]=

Return to the previous directory:

In[5]:=
ResetDirectory[]
Out[5]=

Properties and Relations (1) 

Empty directories have zero bytes:

In[6]:=
ResourceFunction["DirectorySize"][CreateDirectory[]]
Out[6]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 2.0.0 – 29 July 2020
  • 1.0.0 – 12 October 2018

License Information