0

Let's say the program will be run by typing by command line:

python3 program.py Downloads

Here is what I have so far.

import os
path = "Desktop"   //how do I change path to the random user inputed directory provided by command line?

fname = []
for root,d_names,f_names in os.walk(path):
        for f in f_names:
                fname.append(os.path.join(root, f))

print("fname = %s" %fname)

Output:

fname = ['Desktop/Junk.odt']

I need to know how to find the largest file in the given directory and additionally print the filesize

Evan
  • 11
  • 1
  • This will answer your question: https://stackoverflow.com/questions/1392413/calculating-a-directorys-size-using-python – Arpit Maiya Apr 09 '20 at 05:23
  • Thanks, but I think that sums the entire directory I just need the sum of the largest file in the directory – Evan Apr 09 '20 at 05:48
  • The answers are there, you just need to modify the code to do what you want. – Todd Apr 09 '20 at 06:27

0 Answers0