Please use below script to delete all files and folders which are older than 30days,
import os, time, sys,shutil;
path = r'c:\users\Max\downloads'
now = time.time()
for f in os.listdir(path):
fpath=os.path.join(path,f);
if os.stat(fpath).st_mtime < (now - (30 * 86400)):
print 'path',fpath,' will be removed';
if os.path.isfile(fpath):
os.remove(fpath);
if os.path.isdir(fpath):
shutil.rmtree(fpath)
else:
print fpath,'is not older';
Note: ‘path’ is input directory where older files exist.
Sample output would be as below,