Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import subprocess, os
- from collections import Counter
- counter = Counter()
- for path in os.environ['PATH'].split(':'):
- for filename in os.listdir(path):
- output = subprocess.check_output(['file', '-b', os.path.join(path, filename)])
- filetype = ' '.join(output.decode('utf-8').split()[:2])
- counter[filetype] += 1
- for filetype, count in counter.most_common():
- print(count, filetype)
Advertisement
Add Comment
Please, Sign In to add comment