File: count_largefiles.py

package info (click to toggle)
ori 0.8.1%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,204 kB
  • ctags: 2,659
  • sloc: cpp: 22,383; ansic: 5,870; sh: 451; python: 205; makefile: 21
file content (22 lines) | stat: -rw-r--r-- 473 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import os
import os.path
import sys


LF_LIMIT = 1024*1024

num_files = 0
num_largefiles = 0

for root, dirs, files in os.walk(sys.argv[1]):
    #print(root)
    for fn in files:
        fullpath = os.path.join(root, fn)
        num_files += 1
        if os.path.getsize(fullpath) >= LF_LIMIT:
            num_largefiles += 1

print("Large files: {}\nTotal files: {}\nLarge file ratio: {}".format(
    num_largefiles,
    num_files,
    float(num_largefiles) / num_files))