Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- """
- Created on Wed Mar 13 14:39:21 2019
- @author: rodrigo.goncalves
- lista tamanho das pastas no windows
- """
- import os
- from glob import glob
- dir1=input('Dir: >> ')
- dir1=dir1.replace('"','')
- def get_tree_size(path):
- """Return total size of files in given path and subdirs."""
- total = 0
- try:
- for entry in os.scandir(path):
- if entry.is_dir(follow_symlinks=False):
- total += get_tree_size(entry.path)
- else:
- total += entry.stat(follow_symlinks=False).st_size
- except:
- pass
- return total
- ld2=[l for l in glob(dir1+os.sep+'*') if os.path.isdir(l)]
- dicS= {d:get_tree_size(d)*(10**-6) for d in ld2}
- dicS2 = sorted(dicS.items(), key=lambda kv: kv[1])[::-1]
- for v in dicS2:
- print(v[0],'\t',round(v[1],2),'MB')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement