Skip to content

Instantly share code, notes, and snippets.

@zero-shubham
Created July 30, 2019 12:07
Show Gist options
  • Select an option

  • Save zero-shubham/de47cfb332b9007950f6c4ae88d85f62 to your computer and use it in GitHub Desktop.

Select an option

Save zero-shubham/de47cfb332b9007950f6c4ae88d85f62 to your computer and use it in GitHub Desktop.

Revisions

  1. zero-shubham revised this gist Jul 30, 2019. No changes.
  2. zero-shubham created this gist Jul 30, 2019.
    12 changes: 12 additions & 0 deletions recursive_dir_size
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    import os

    def recursive_dir_size(path):
    size = 0

    for x in os.listdir(path):
    if not os.path.isdir(os.path.join(path,x)):
    size += os.stat(os.path.join(path,x)).st_size
    else:
    size += recursive_dir_size(os.path.join(path,x))

    return size