Skip to content

Instantly share code, notes, and snippets.

@haniehrajabi
Last active October 20, 2015 13:42
Show Gist options
  • Select an option

  • Save haniehrajabi/84472f14481e9f0de417 to your computer and use it in GitHub Desktop.

Select an option

Save haniehrajabi/84472f14481e9f0de417 to your computer and use it in GitHub Desktop.
#! /usr/bin/python
import sys, os, operator
from os.path import isfile, join, getsize
def list_files(path):
binned_ranges = {}
for dirpath, dirnames, filenames in os.walk(path):
for filename in filenames:
filesize=os.stat(os.path.join(dirpath,filename)).st_size
base = 1024
while True:
print("Filesize %d base %d name %s") % (filesize,base,os.path.join(dirpath,filename))
if filesize < base:
try:
binned_ranges[base]+=1
except KeyError:
binned_ranges[base]=1
break
else:
base = (base * 4)
print binned_ranges
return 0
if __name__ == "__main__":
argument_len=len(sys.argv)
if argument_len < 2:
raise ValueError("Please specify your directory path")
else:
list_files(sys.argv[1])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment