Recursive File Filtering

Recursive File Filtering

Recursive File Filtering

Instructions

Create a simple Python application (Save as w5_firstname_lastname.py) .

Create 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)

4) Optionally, you can save the list into a file “Results.txt” using the redirection operator, do not create the file in the script.

Submit your week 5 work in w5_firstname_lastname.txt (Please save the file as a text file and upload the text file here for final review.)

Recursive File Filtering

Check our Python Programming writing services

APA

Recursive File Filtering

The Python script, saved as w5_john_doe.py, is designed to list files in a specified folder and its subfolders that exceed a given size threshold, providing their names, sizes, and creation dates. It accepts two command-line parameters: the root folder path and a minimum file size (in bytes). The script validates inputs by checking if the folder exists and if the size is a non-negative integer, using a try-except block to handle errors gracefully with user-friendly messages that avoid exposing code details. It employs the os.walk function to recursively traverse the folder and its subfolders, retrieving file metadata via os.stat. Files larger than the specified size are printed in a formatted table, including the file path, size, and creation date, formatted using datetime. Errors like permission issues are caught and reported without halting the program. The output can be redirected to Results.txt using the command line, as the script avoids creating files internally. This ensures robust, error-resistant functionality for analyzing file systems, suitable for submission as a text file (w5_john_doe.txt) for review, meeting the assignment’s requirements for validation, error handling, and output flexibility.