Bash a script that downloads and reports upon all of a user-specified image type, e.g. png, jpg, jpeg, gif, at a

user-provided URL.

Required Script Functionality

▪ The user is to be prompted for the desired URL and image type

▪ Your assessor will always enter a valid URL, so you don’t need to validate for this

▪ Your script is to scan for and download images of the following four (4) types only:

1. .jpg

2. .jpeg

3. .gif

4. .png

▪ Keep in mind that URLs often contain multiple copies of the same image file, hyperlinked in different

locations on the page users interact with, therefore, your code will need to account for this so that

such duplicates, where they exist, are neither downloaded nor displayed in the final summary or any

of its statistics

▪ URLs that contain no image files of the allowed types will also be used during the assessment

process, so your script will need to allow for this scenario as well, informing the user of this with an

appropriate terminal message when it occurs and exiting the script exited gracefully

▪ In the event that allowable image file(s) of the type the user stipulates are available at the URL

provided, all of them must be downloaded from the URL and stored in a directory with a unique

name that will not conflict with any other directories that currently exist or which may be created in

the future

▪ It is the responsibility of the script to handle directory naming and creation, not the users’.

▪ Once all allowed image files have been downloaded from the URL provided (where they exist), the

following information is to be displayed to the terminal in a neat and easy-to-read format:

o A count of how many were downloaded (excluding duplicates, where they exist)

o The directory name into which they were downloaded

o A tabulated summary, with an appropriate header, of all of the image files downloaded

(excluding duplicates, where they exist) and the size of each on disk in bytes, kilobytes or

megabytes as applicable

▪ Your script is also to accommodate an optional -z option (to be used at the command line) that,

when used, will facilitate the adding of all the downloaded image files to a zip archive that is to

reside in the same directory as the downloaded image files and given the same name as this

directory

▪ When the -z option is used, the user is to be informed that the requested zip archive has been

created successfully and where it is located as part of the final summary output

▪ If the user provides an invalid flag, or any other invalid input at all, at the command line, they are to

be informed of this with an appropriate error message and the script terminated with an

appropriate exit code

More Rajwinder Kaur's questions See All
Similar questions and discussions