Python 3 Automation Script to Delete All Files Inside a Directory Older than X Days Using OS and Time Modules Full Project For Beginners

You are currently viewing Python 3 Automation Script to Delete All Files Inside a Directory Older than X Days Using OS and Time Modules Full Project For Beginners

 

Welcome folks today in this blog post we will be removing all files older than x days using os module and time module in python. All the full source code of the application is given below.

 

 

Get Started

 

 

In order to get started you need to make an app.py file and copy paste the following code

 

app.py

 

 

 

Here in this above script it will automatically delete all files which are older than 4 days you can change this value according to your situation.

 

Now if you execute the above script by typing the below command as shown below

 

python app.py

 

Leave a Reply