Skip to content

Instantly share code, notes, and snippets.

@3rogue
Last active August 29, 2015 14:28
Show Gist options
  • Select an option

  • Save 3rogue/10e74767be6e75f4a436 to your computer and use it in GitHub Desktop.

Select an option

Save 3rogue/10e74767be6e75f4a436 to your computer and use it in GitHub Desktop.

Revisions

  1. 3rogue revised this gist Aug 25, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion filesize.py
    Original file line number Diff line number Diff line change
    @@ -12,4 +12,4 @@ def list_size(path):
    path = 'E:'
    with open ('1.txt','w') as f:
    for i in list_size(path):
    f.write(i[0]+'\t'+str(i[1])+'\n')
    f.write(i[0]+'\t'+str(i[1])+'MB'+'\n')
  2. 3rogue created this gist Aug 25, 2015.
    15 changes: 15 additions & 0 deletions filesize.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    import os

    def list_size(path):
    res={}
    for dirpath, dirnames, filenames in os.walk(path):
    for name in filenames:
    fullpath = os.path.join(dirpath, name)
    size = os.path.getsize(fullpath)
    res[fullpath] = size/1024/1024
    return sorted(res.items(), key = lambda d:d[1], reverse = True)

    path = 'E:'
    with open ('1.txt','w') as f:
    for i in list_size(path):
    f.write(i[0]+'\t'+str(i[1])+'\n')