Skip to content

Commit 8a89b23

Browse files
Merge pull request geekcomputers#99 from aaronthj16/folder-size
Added argument support to folder_size.py
2 parents d9768e2 + ebe48ce commit 8a89b23

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

folder_size.py

100644100755
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88

99
# Description : This will scan the current directory and all subdirectories and display the size.
1010

11-
import os # Load the library module
12-
directory = '.' # Set the variable directory to be the current directory
11+
import os, sys # Load the library module and the sys module for the argument vector
12+
try:
13+
directory = sys.argv[1] # Set the variable directory to be the argument supplied by user.
14+
except IndexError:
15+
sys.exit("Must provide an argument.")
1316
dir_size = 0 # Set the size to 0
1417

1518
fsizedicr = {'Bytes': 1, 'Kilobytes': float(1)/1024, 'Megabytes': float(1)/(1024*1024), 'Gigabytes': float(1)/(1024*1024

0 commit comments

Comments
 (0)