Delete largest file from a directory using Python

In this tutorial, we will learn how to delete largest file from a directory using  Python with some cool and easy examples. In many situations, you might have to come up with this type of requirements.

I know you are here just because you are in need of this awesome trick to delete largest file from a directory using Python.

If you don’t know how to delete largest file from a directory  then you are at the right place. Because in this tutorial we gonna find out to delete largest file from a directory using Python.

import os
file='file1.txt'
location = "D:/pycharm projects/GeeksforGeeks/Authors/Nikhil/"
path os.path.join(location,file)
os.remove(path)





OUTPUT:

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top