Instructions: You will write a Python module named “your1stname_yourlastname_files.py” that will contain several functions to perform the following tasks in the prescribed order. Your program should have the statement “if __name__ == __main__” at the bottom, which will kick-start the execution of your module. Phase 0: Tell the user what the code is doing at runtime   For every task, your Python code should display what it is about to do before starting, and inform the user when the task is done. This will also help you with the architecture of your code and debugging.   Phase 1: Automated creation of directories and files   2. Create a directory named “your1stname_yourlastname_DIR” in the “Documents” directory of your computer.   Inside the “your1stname_yourlastname_DIR” directory, automate the creation of directories and files according to the tree structure in Figure 1. You should find patterns and the file/folder names that would allow you to achieve this through a few loops. For instance, you may create variables such as “folder” and “image” and use them to generate names automatically. Phase 2: Create a work copy or a directory In real life, it is a good practice to create a duplicate of a folder/file on which you will be working and work on the copy rather than on the original. This will help you preserve the document is things go wrong. Replicate the content of “your1stname_yourlastname_DIR” into a new directory named “your1stname_yourlastname_DIR-CP” that you will create inside your “Documents” folder. Phase 3: Manipulations In real life, you will have to modify files, rename files, delete files, or archive (zip) files. Go through “your1stname_yourlastname_DIR” and delete all “.txt” files that your encounter. The files should be recoverable from the recycle bin. Inside “your1stname_yourlastname_DIR-CP” rename all files with names ending in “2.jpg” by replacing this ending with “2.pdf.” This means you will alter those files into .pdf files. Identify all the .pdf files that you created above, and archive them together in a single “.gzip” archive file named “pdf2.gzip.” Move the pdf2.gzip file to “your1stname_yourlastname_DIR.” In “your1stname_yourlastname_DIR,” create a file named ”listofall.txt” as a record where you list all the files and folders that remain in “your1stname_yourlastname_DIR-CP,” and then delete “your1stname_yourlastname_DIR-CP” irreversibly, meaning it cannot be recovered. Not more that one file/folder name should be on the same line. Phase 4: Backups In real life, you will have to write codes to packup documents. Create a “Backup” folder in your “Downloads” directory to backup the “pdf2.gzip” and ”listofall.txt” files. Phase 5: Visual representation You need to verify that your code performed the right modifications. For directories and files, plotting a tree structure is usually used. Display a tree structure of “your1stname_yourlastname_DIR,” similar to the one in Figure 1.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Instructions:

You will write a Python module named “your1stname_yourlastname_files.py” that will contain several functions to perform the following tasks in the prescribed order. Your program should have the statement “if __name__ == __main__” at the bottom, which will kick-start the execution of your module.

Phase 0: Tell the user what the code is doing at runtime

 

  1. For every task, your Python code should display what it is about to do before starting, and inform the user when the task is done. This will also help you with the architecture of your code and debugging.

 

Phase 1: Automated creation of directories and files

 

2. Create a directory named “your1stname_yourlastname_DIR” in the “Documents” directory of your computer.

 

  1. Inside the “your1stname_yourlastname_DIR” directory, automate the creation of directories and files according to the tree structure in Figure 1. You should find patterns and the file/folder names that would allow you to achieve this through a few loops. For instance, you may create variables such as “folder” and “image” and use them to generate names automatically.

Phase 2: Create a work copy or a directory

In real life, it is a good practice to create a duplicate of a folder/file on which you will be working and work on the copy rather than on the original. This will help you preserve the document is things go wrong.

  1. Replicate the content of “your1stname_yourlastname_DIR” into a new directory named “your1stname_yourlastname_DIR-CP” that you will create inside your “Documents” folder.

Phase 3: Manipulations

In real life, you will have to modify files, rename files, delete files, or archive (zip) files.

  1. Go through “your1stname_yourlastname_DIR” and delete all “.txt” files that your encounter. The files should be recoverable from the recycle bin.
  2. Inside “your1stname_yourlastname_DIR-CP” rename all files with names ending in “2.jpg” by replacing this ending with “2.pdf.” This means you will alter those files into .pdf files.
  3. Identify all the .pdf files that you created above, and archive them together in a single “.gzip” archive file named “pdf2.gzip.” Move the pdf2.gzip file to “your1stname_yourlastname_DIR.”
  4. In “your1stname_yourlastname_DIR,” create a file named ”listofall.txt” as a record where you list all the files and folders that remain in “your1stname_yourlastname_DIR-CP,” and then delete “your1stname_yourlastname_DIR-CP” irreversibly, meaning it cannot be recovered. Not more that one file/folder name should be on the same line.

Phase 4: Backups

In real life, you will have to write codes to packup documents.

  1. Create a “Backup” folder in your “Downloads” directory to backup the “pdf2.gzip” and ”listofall.txt” files.

Phase 5: Visual representation

You need to verify that your code performed the right modifications. For directories and files, plotting a tree structure is usually used.

  1. Display a tree structure of “your1stname_yourlastname_DIR,” similar to the one in Figure 1.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
File Input and Output Operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education