all the info are in the zip file
TP4/Backup/asupprimer.txt dsfsdf TP4/Documents/asupprimer.txt dsfsdf TP4/Musique/asupprimer.txt dsfsdf TP4/T?l?chargement/Musique2.wav TP4/T?l?chargement/MusiqueMusique.mp3 Impact Moderato Kevin MacLeod YouTube Audio Library Cinematic 27193.623 TP4/T?l?chargement/MusiqueMusique3.mp3 Impact Moderato Kevin MacLeod YouTube Audio Library Cinematic 27288.0 TP4/T?l?chargement/Test.txt test TP4/T?l?chargement/Test2.txt test2 TP4/T?l?chargement/Test3.txt test3 TP4/T?l?chargement/Vid?o.mp4 Lavf53.24.2 TP4/T?l?chargement/Vid?o2.mkv TP4/T?l?chargement/Vid?o3.mp4 Lavf53.24.2 TP4/Vid?o/asupprimer.txt dsfsdf tp4.docx S12 - TP4 (15%) File management Your names: For this last TP we will make a Python3 program that will allow us to manage our files in Linux. To make sure we don't break anything, we will start by creating our working directories. So in your Linux installation create the following structure (provided in the ZIP file): - TP4 o Backup o Download Test.txt Test2.txt Test3.txt Music.mp3 Music2.wav Music3.mp3 Video.mp4 Video2.mkv Video3.mp4 o Documents o Music o Video For this tutorial we will have classes and a Main. To simplify, you can put all the classes and the Main in the same .py file. - Class Item : Basic class. We keep the name of the item, the complete path of the item, the last modification date of the item. ( / 5 pts) - Class Folder : Class which inherits from Item. We keep the types of files which must go in this folder (array). Example : MP3, WAV... o Method __init__(self, name, path, creation, extension, pathBackup) : ( / 5 pts) Name : name of the file (ex : test.xt) Path : the directory where it is located (ex : \home\patrick\t4\documents\) Creation : when the file has been created on the disk TypeFiles : an array of extensions. That is to say the types of files which go in this directory. (ex : .mp3, .wav...) o Method AddExtension(self, extension) : ( / 5 pts) Allows to add an extension to this folder. o RemoveExtension method (self, extension) : ( / 5 pts) Allows to remove an extension to this folder. - Class File : Class that inherits from Item. We keep the file extension, the complete path of the last backup. o Method __init__(self, name, path, creation, extension, pathBackup) : ( / 5 pts) Name : name of the file (ex : test.xt) Path : the directory where it is located (ex : \home\patrick\t4\documents\) Creation : when the file was created on the disk Extension : the extension of the file (ex : .txt) pathBackup : The path of the backup folder (ex : \home\patrick\t4\backup) o Method TakeBackup(self) : ( / 20 pts) This method will copy the file in the folder " Backup ". One adds the date and hour of the copy following the extension. Example : myfile.txt myfile.txt_2021-01-14 13:46:35 We check the number of backups of this file present in the "Backup" folder and we delete the oldest if there are more than 3. o Method MoveToGoodFolder() : ( / 15 pts) This method will move the file to the right folder based on the extension. You must find the right folder by browsing your folder list and looking at the associated file types. - Hand: Here is what your hand should do. 1.Declaration of an empty array named ListItem. ( / 3 pts) 2.Browse through all the folders and files in the TP4 directory. So in a For loop, if you encounter a file, you instantiate an object of type File with the appropriate construction info. If it is a folder, you instantiate an object of type Folder with the appropriate construction info. For folders the file types are: document folder = txt, music folder = mp3 and wav, video folder = mp4 and mkv. ( / 16 pts) From here on you ListItem table should be filled with file and folder type objects. 3.Find the folder "Video" in listeItem. ( / 3 pts) 4.Add the extension ".avi" to the folder and display the extensions of the folder. ( / 3 pts) 5.Remove the ".avi" extension from the folder and display the extensions of the folder. ( / 3 pts) 6.Display all the files present in the "Backup" folder. ( / 3 pts) 7.For all the files with the extension ".txt", take a backup by calling the method of the file class " TakeBackup ". ( / 3 pts) 8.Repeat point 6 and 7 four (4) times. Use a loop ( / 3 pts) 9.Move all files with the extension ".mp3" to the right folder. This is done by calling the "MoveToGoodFolder" method of the File class. ( / 3 pts) ***IMPORTANT: Take one or more screen prints of the execution of your hand. *** Import: - Here are some imports you may need. You can use others of course. o import os o import shutil o import datetime o import glob o import time Delivery: - This document with the screen prints of the execution of Main. - Your .py which contains all the code of your TP4. Translated with www.DeepL.com/Translator (free version)