Workshop 1
Workshop 1
The goal is to develop a Shell script that analyzes the contents of a given directory,
automatically sorts files by type, and organizes them into dedicated subfolders. At the end of
the process, an execution report will be generated to summarize the operations performed.
Features
1. The script must check for at least one argument; otherwise, it should display the usage
message on the error output and fail.
2. The script must verify if the argument exists and whether it is a directory. If not, it should
prompt the user to provide the name of an existing directory. It must then scan all files within
this directory (without descending into subdirectories).
3. The script must identify the file type based on its extension or by using the file or mimetype
command.
4. The script must classify files into the following categories:
o Text: .txt, .md, .csv, .log
o Images: .jpg, .jpeg, .png, .gif, .bmp
o Videos: .mp4, .avi, .mkv, .mov
5. The script must create the corresponding subfolders if they do not exist and move the files into
their respective subfolders.
6. The script must generate a text file script_report.txt containing:
o The total number of files processed.
o The number of files per category.
o The date and time of script execution.
Guidelines
To execute and test the requested script, a test environment must be prepared. This consists of
a directory inside the user's home directory that contains files of different types as indicated in
the script (images, videos, etc., can be downloaded).
The code must be well-structured and commented.