Advertisement
Guest User

Zadatak

a guest
Mar 28th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. import os, math
  2.  
  3. fileList = {}
  4. for root, dirs, files in os.walk("."):
  5.     for file in files:
  6.         filename, file_ext = os.path.splitext(file)
  7.         if len(file_ext) > 0:
  8.             if file_ext in fileList:
  9.                 fileList[file_ext]['count'] += 1
  10.                 fileList[file_ext]['size'] += os.path.getsize(root + os.sep + file)
  11.             else:
  12.                 fileList[file_ext] = {'count': 1, 'size': os.path.getsize(root + os.sep + file)}
  13.  
  14. for ext, file in fileList.iteritems():
  15.     kbSize = math.ceil(file['size'] / 1024)
  16.     args = [file['count'], str(int(kbSize)) + 'kb', ext]
  17.     print '{0:<10} {1:>8} {2:>8}'.format(*args)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement