Final answer:
A Python script was provided to create a 'week3' folder, monitor it for new files, and report details about any new files found, including type and time added.
Step-by-step explanation:
To address the student's request, we'll provide a Python script that accomplishes the following:
- Creates a folder named "week3".
- Contains a loop that monitors the folder for new files.
- Reports back details about any new files found.
The Python script uses the os and time modules for creating the folder and checking file presence, and the os.path module for retrieving file details. Here is an example script:
import os
import time
folder_name = 'week3'
if not os.path.exists(folder_name):
os.mkdir(folder_name)
observed_files = set(os.listdir(folder_name))
while True:
current_files = set(os.listdir(folder_name))
new_files = current_files - observed_files
if new_files:
for file in new_files:
file_path = os.path.join(folder_name, file)
file_info = os.stat(file_path)
print('File found:', file)
print('Type of file:', file.split('.')[-1])
print('Time put there:', time.ctime(file_info.st_ctime))
observed_files = current_files
time.sleep(1)
The script continuously checks for new files and provides the user with information about them.