Hello,
I am creating several directories a day. After seven days I am going to drop a sandbox in these directories and delete them. I use a time stamp to name them. I have got some code below to show you what I have got.
today = datetime.date.today() # Today's date Binary
todaystr = datetime.date.today().isoformat() # Todays date as a string
minus_sevent = today - datetime.timedelta(days = 7) # 7 days ago as a string
minus_seven = minus_sevent.isoformat()
old_folders = minus_seven + '*'
def delete_sandbox():
if os.path.exists(old_folders):
os.chdir(old_folders)
mks_drop_sandbox()
os.chdir(rootDir)
for filename in glob.glob(old_folders):
shutil.rmtree(old_folders)
print 'Sandboxes from 7 days ago removed'
if __name__ == '__main__': myObject = delete_sandbox()
This was similar code I used before to drop a sandbox and delete a one directory. But there may be several builds done in the days and I want to know how to enter each folder and do these tasks.
Folders in the directories will be created with their time as well as their date, I have variables that just remove all folders of a set date regardless of time.
Thanks