Python 3 Script to Delete Windows Temporary Files Using OS Module Full Project For Beginners

 

 

Welcome folks today in this blog post we will be deleting windows temporary files using os module in python 3. All the full source code of the application is shown below.

 

 

 

Get Started

 

 

 

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

 

 

app.py

 

 

import os, subprocess
del_dir = r'c:\windows\temp'
pObj = subprocess.Popen('del /S /Q /F %s\\*.*' % del_dir, shell=True, stdout = subprocess.PIPE, stderr= subprocess.PIPE)
rTup = pObj.communicate()
rCod = pObj.returncode
if rCod == 0:
    print 'Success: Cleaned Windows Temp Folder'
else:
    print 'Fail: Unable to Clean Windows Temp Folder'

Leave a Reply