diff --git a/folder_size.py b/folder_size.py old mode 100644 new mode 100755 index f79c9449b96..d89f2232e28 --- a/folder_size.py +++ b/folder_size.py @@ -8,8 +8,11 @@ # Description : This will scan the current directory and all subdirectories and display the size. -import os # Load the library module -directory = '.' # Set the variable directory to be the current directory +import os, sys # Load the library module and the sys module for the argument vector +try: + directory = sys.argv[1] # Set the variable directory to be the argument supplied by user. +except IndexError: + sys.exit("Must provide an argument.") dir_size = 0 # Set the size to 0 fsizedicr = {'Bytes': 1, 'Kilobytes': float(1)/1024, 'Megabytes': float(1)/(1024*1024), 'Gigabytes': float(1)/(1024*1024