Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will create a directory lister that will walk a filesystem to determine the largest subdirectories it contains and display each of these directories along

You will create a directory lister that will walk a filesystem to determine the largest subdirectories it contains and display each of these directories along with the size of that directory. The size of a directory in this case is defined as the total size of all files contained in that directory.

Requirements

Accept command line input.You will need to import the sys module for this.

oYour program should accept 1 argument, a path to the directory where you want to start.

Traverse the filesystem starting at the user specified directory. The os module has several useful methods for this

o Be sure to include the starting directory

o Recursively traverse all subdirectories

Output the 5 largest subdirectories found. If there are fewer than 5, output all of them.

o Your output should be written in the closest appropriate unit:

987 bytes would be written as 987 B

15,224 bytes would be written as 14.87 KiB

1,231,569 bytes would be written as 1.17 MiB

and so on through TiB

The last line of output should be the total of the 5 largest subdirectories found.

You are not allowed to use a system command such as du that will do the work for you. It must be your own code that walks the filesystem, collects the relevant info, and displays it.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

Find v(t) for the circuit in Fig. 13.77. 4 2 cos 4r

Answered: 1 week ago

Question

What lessons in OD contracting does this case represent?

Answered: 1 week ago

Question

Does the code suggest how long data is kept and who has access?

Answered: 1 week ago