Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/python3
import os
import glob
import sys
try:
my_path = sys.argv[1]
except:
print("Please enter a valid path.")
quit()
ocurrences = dict()
for i in range(1, 10):
ocurrences[i] = 0
total_files = 0
files = [file for file in glob.glob(my_path + '/**/*', recursive=True)]
for item in files:
total_files += 1
size = str(os.path.getsize(item))[0]
ocurrences[int(size)] += 1
for item in ocurrences:
print("{0} --> {1} times ({2:0.2f}%)".format(item, ocurrences[item], float((ocurrences[item] * 100) / total_files)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.