找出超过1年目录的python脚本:
注:
1、datetime.timedelta代表2个时间的时间差
vi a1.py
#!/usr/bin/python
import os
import datetime
dir="/home"
now = datetime.datetime.now()
delta = datetime.timedelta(days=365)
os.chdir(dir)
for root,dirs,files in os.walk(dir):
for f in dirs:
if f == "aa":
mtime = datetime.datetime.fromtimestamp(os.path.getmtime(os.path.join(root,f)))
if mtime < (now - delta):
print os.path.join(root,f)
:wq
python a1.py
原文地址:http://blog.51cto.com/yangzhiming/2127925
时间: 2024-10-08 13:38:11