18 lines
406 B
Python
18 lines
406 B
Python
import os
|
|
|
|
def walkPath(root):
|
|
extensions = {}
|
|
for root, dirs, files in os.walk(root):
|
|
for file in files:
|
|
ext = os.path.splitext(file)[1]
|
|
try:
|
|
extensions[ext] += 1
|
|
except KeyError:
|
|
extensions[ext] = 1
|
|
sortedExts = sorted(extensions.items(), key=lambda x: x[1])
|
|
for ext, count in reversed(sortedExts):
|
|
print(ext, '\t\t', count)
|
|
|
|
if __name__ == "__main__":
|
|
walkPath(os.getcwd())
|