Make a simple Python application (Save as w5_firstname_lastname.py) . make a Python script that takes two parameters to do the
Make a simple Python application (Save as w5_firstname_lastname.py) .
make a Python script that takes two parameters to do the following:-
1) List all files names, size, date created in the given folder
2) Parameter1 = Root Folder name
Parameter2= File size >>> to filter file size ( you can do =, > or <) it is up to you, or a range.
The script should check and validate the folder name, and the size
The script should loop until find all files greater than the specified size in all the sub-folders
3) Use try-exception block (Make sure that the error messages do not reveal any of the application code)
Create the following code but keep receiving an error, Also I'm trying to run the file from CMD and do not know the correct format that will properly run it and show file details. Please check the code for errors and help me with the CMD script to run the file showing what the file contains.
import os, sys, time
path = "." #parameter 1, Root Folder
dirs = os.listdir(path)
print("Error: can't find file or read data")
toolarge = 0
print(str("FILE").ljust(34), str("SIZE").ljust(16), str("DATE CREATED").ljust(10), end=" ")
print("------------------ ------------ -----------------")
for file in dirs:
filesize = os.stat(file).st_size #parameter 2, file size
if (filesize <= 10000): #file size filter to files <= 10000 bytes
print(str(file).ljust(30), repr(os.stat(file).st_size).rjust(8), end = ' ')
toolarge = toolarge + 1
print("There are", toolarge, "files that exceed directory filter paramteres.")