Write a complete program that prints out the list of files in the current directory, along with their file sizes and last modified datetime stamps. Any sub-directories are ignored. At the end, print the total file size.

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
Write a complete program that prints out the list of files in the current directory,
along with their file sizes and last modified datetime stamps. Any sub-directories are
ignored. At the end, print the total file size.
It accepts two optional command-line arguments:
Sort field (single sort key
only)
“name" for filename,
"size" for file size,
1
"date" for last modified
datetime stamp,
default is “name".
"asc" for ascending,
"desc" for descending,
2
Sort order
default is “asc".
A sample execution of the program with both command line arguments provided is
shown below.
$ python q3a.py date desc
Filename
Size
Last Modified
fileSorter.py / 1461 / Sat Jan 30 01:40:48 2021
optimized_fib.py / 273 / Fri Jan 29 10:53:45 2021
tic-tac-toe-bot-master.zip / 37180 / Thu Jan 28 15:12:03 2021
tictactoe.py / 8157 / Thu Jan 28 14:59:45 2021
getComputerMove.py / 1131 / Thu Jan 28 14:55:22 2021
Total file size: 48203
Research how you access the file system using the functions in the os module. You
may use Python’s built-in sort() function to perform the sort.
Transcribed Image Text:Write a complete program that prints out the list of files in the current directory, along with their file sizes and last modified datetime stamps. Any sub-directories are ignored. At the end, print the total file size. It accepts two optional command-line arguments: Sort field (single sort key only) “name" for filename, "size" for file size, 1 "date" for last modified datetime stamp, default is “name". "asc" for ascending, "desc" for descending, 2 Sort order default is “asc". A sample execution of the program with both command line arguments provided is shown below. $ python q3a.py date desc Filename Size Last Modified fileSorter.py / 1461 / Sat Jan 30 01:40:48 2021 optimized_fib.py / 273 / Fri Jan 29 10:53:45 2021 tic-tac-toe-bot-master.zip / 37180 / Thu Jan 28 15:12:03 2021 tictactoe.py / 8157 / Thu Jan 28 14:59:45 2021 getComputerMove.py / 1131 / Thu Jan 28 14:55:22 2021 Total file size: 48203 Research how you access the file system using the functions in the os module. You may use Python’s built-in sort() function to perform the sort.
Expert Solution
steps

Step by step

Solved in 3 steps with 5 images

Blurred answer
Knowledge Booster
Files and Directory
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