-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsizeof
More file actions
executable file
·26 lines (21 loc) · 756 Bytes
/
Copy pathsizeof
File metadata and controls
executable file
·26 lines (21 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#! /usr/bin/env python
import os
import sys
from hurry.filesize import size, alternative
cwd = os.getcwd()
arguments = sys.argv[1:]
if len(arguments) == 0:
arguments.append('.')
for arg in arguments:
current_arg = os.path.join(cwd, arg)
if (os.path.isdir(current_arg)):
folder_size = 0
for (path, dirs, files) in os.walk(current_arg):
for f in files:
filename = os.path.join(path, f)
if os.path.isfile(filename):
folder_size += os.path.getsize(filename)
print str(size(folder_size, system=alternative)) + "\t" + arg
else:
file_size = size(os.path.getsize(current_arg), system=alternative)
print str(file_size) + "\t" + arg