이 당신을 위해 작동 할 수있다 : -
import os
import datetime as dt
import shutil
now = dt.datetime.now()
ago = now-dt.timedelta(minutes=30) #Mention the required time
for root, dirs,files in os.walk('/home/piyush/pppptest'): #put required directory path
for fname in files:
path = os.path.join(root, fname)
st = os.stat(path)
mtime = dt.datetime.fromtimestamp(st.st_mtime) #Gives you the modified time of file
# print mtime
if mtime > ago:
print('%s modified %s'%(path, mtime)) #You can check path and modified and work on it as per your requirement
shutil.rmtree('path') #You can delete it.