View difference between Paste ID: FnBCgHUm and 1JEMndwr
SHOW: | | - or go back to the newest paste.
1
import subprocess, os
2
from collections import Counter
3
4
counter = Counter()
5
for path in os.environ['PATH'].split(':'):
6
  for filename in os.listdir(path):
7-
    output = subprocess.check_output(['file', '-b', os.path.join(path, filename)])
7+
    output = subprocess.check_output(['file', '-b', '--', os.path.join(path, filename)])
8
    filetype = ' '.join(output.decode('utf-8').split()[:2])
9
    counter[filetype] += 1
10
11
for filetype, count in counter.most_common():
12
  print(count, filetype)