我有一个脚本删除比日期更早的图像.
当我打电话来运行脚本时,我可以将此日期作为参数传递吗?
示例:此脚本delete_images.py删除早于日期的图像(YYYY-MM-DD)
python delete_images.py 2010-12-31
Run Code Online (Sandbox Code Playgroud)
脚本(使用固定日期(xDate变量))
import os, glob, time
root = '/home/master/files/' # one specific folder
#root = 'D:\\Vacation\\*' # or all the subfolders too
# expiration date in the format YYYY-MM-DD
### I have to pass the date from the script ###
xDate = '2010-12-31'
print '-'*50
for folder in glob.glob(root):
print folder
# here .jpg image files, but could be .txt files or whatever
for image in glob.glob(folder + '/*.jpg'):
# retrieves the stats …Run Code Online (Sandbox Code Playgroud)