You are given a directory from a webserver that contains multiple HTML ?les… 1 answer below »
You are given a directory from a webserver that contains multiple HTML ?les… 1 answer below »
AssignmentTask 1: Script programmingConsider the following situation:You are given a directory from a webserver that contains multiple HTML ?lesas well as multiple ?les of other types (e.g. images). The directory may containsubdirectories. You are asked to clean up this directory and its subdirectoriesby removing all unused ?les. A ?le is considered unused if it is not linked in anyof the HTML ?les or if it is not speci?ed explicitly that this ?le is in use. A ?lecan be linked in a HTML ?le by either a href or img src. It does not matterwhether the link is within a commented-out section of the HTML ?le. Do notremove subdirectories.The ?les you remove must be stored in a user-speci?ed directory. You needto maintain the directory structure when storing the removed ?les (e.g. if youremove two ?les a/b/a.txt and a/a.txt, both ?les must be stored under theirdirectories).You also need to create statistics output for the ?les that have been removed.The statistics output must be in text form and must contain, for each ?le ending,the number of ?les and the overall size of ?les with that ending. In addition, thenumber and size of all removed ?les needs to be reported. For this purpose, ?leendingsare not case-sensitive (i.e. .gif and .GIF are considered the same forstatistics purposes). The statistics must also contain the name of the directoryon which the cleanup script has been run.T1.1: Write a Perl script to automate this task. The script must be run as follows:cleanup.pl [CleanupDir] [RubbishBinDir] [ListOfUsedFiles]where[CleanupDir ] is the name of the directory to clean up.[RubbishBinDir ] is the name of the directory where removed ?les are to be stored.[ListOfUsedFiles ] is a list of 0 or more ?les that are in use and should not be deleted.Your script must handle errors such as missing parameters, missing ?les, missing directories,missing access permissions, or input/output errors gracefully, that is, it mustnot crash on encountering them. Depending on what is appropriate, your script mayhandle errors by displaying a warning and continuing, by displaying an error messageand aborting, or by taking other actions (e.g. creating a missing directory). Your scriptshould try to ?x problems, if this is possible.T1.2: Discuss, in at most 300 words, why script programming is particularly suited for thisproblem, and describe two possible extensions of your script and how they could beachieved.2