Computer Sciences Department logo

CS 368-1 (2011 Summer) — Day 6 Homework

Due Thursday, July 21, at the start of class.

Description

Starting at a given directory, find all of the directories contained inside recursively. Then, for each directory found, display the directory name and information about the files found inside. To be successful, you will use many built-in functions and modules.

Details

The script will take one directory path as input — either ask the user for the directory or simply hard-code it into your script. Then, starting at that directory, search for and store all directories contained inside (including the given one) recursively.

Then, go through the directories that you found and display a report for each one:

You may assume that there are only regular files and directories.

Example Output

Directory </p/course/cs368-cat/public/html/2010>
        9641   2010-07-01 16:25:22   resources.html
        7068   2010-07-20 13:59:20   index.html
        1541   2009-07-08 09:52:37   cs-logo.gif
         707   2010-07-20 16:16:16   homework-08-ideas.pl
         658   2009-07-10 15:49:32   368-1.css

Directory </p/course/cs368-cat/public/html/2010/01-introduction>
      115281   2010-07-12 10:18:22   cs368-1-2010-summer-01-0712M.pdf
        2369   2010-07-12 09:51:49   homework-01-assignment.html

Directory </p/course/cs368-cat/public/html/2010/02-syntax>
      131814   2010-07-13 09:56:27   cs368-1-2010-summer-02-0713T.pdf
        2974   2010-07-13 10:02:07   homework-02-assignment.html
         642   2010-07-13 16:40:02   in-class-code.html

Directory </p/course/cs368-cat/public/html/2010/03-collections>
      114186   2010-07-15 09:44:21   cs368-1-2010-summer-03-0715R.pdf
        4144   2010-07-15 09:53:12   homework-03-assignment.html

Directory </p/course/cs368-cat/public/html/2010/04-basic-io>
     1454670   2009-07-13 13:46:40   homework-04.txt
      132377   2010-07-16 10:12:51   cs368-1-2010-summer-04-0716F.pdf
        3389   2010-07-16 10:34:29   homework-04-assignment.html

Directory </p/course/cs368-cat/public/html/2010/05-subroutines>
      113456   2010-07-19 10:08:07   cs368-1-2010-summer-05-0719M.pdf
        3213   2010-07-19 10:30:29   homework-05-assignment.html
        1133   2010-07-19 14:39:02   in-class-code.html

Directory </p/course/cs368-cat/public/html/2010/06-data-structures>
      237215   2009-07-20 23:57:39   example_access_log
      124530   2010-07-20 09:49:22   cs368-1-2010-summer-06-0720T.pdf
        8092   2010-07-20 10:14:27   homework-06-assignment.html

Directory </p/course/cs368-cat/public/html/2010/08-standard-library>
        2484   2010-07-20 16:15:22   homework-08-assignment.html

Hints

The following hints are a bit … vague. I am doing this to encourage you to look up some functions and modules online. You need to learn to do this anyway, so consider it good practice.

Extra Challenges

Reminders

Do the work yourself, consulting reasonable reference materials as needed; any reference material that gives you a complete or nearly complete solution to this problem or a similar one is not OK to use. Asking the instructors for help is OK, asking other students for help is not.

Hand In

A printout of your code on a single sheet of paper. Be sure to put your own name in the initial comment block of the code. Identifying your work is important, or you may not receive appropriate credit.