I am using ArcGIS Desktop 10.0 and Python 2.6.6 and am trying to make an update script to copy the geodatabase to a backup folder with the date as part of the name, got that to work.
Then export features from my editing geodatabase to the one on our server, got that working.
But now I want to, at the end of my script, to go back to the backup folder and delete any geodatabases there that are older than 1 week to keep it clean.
Tried a number of ways but they didn't work, any suggestions?
import re import os import datetime import time import sys from subprocess import call now = time.time() cutoff = now - (7 * 86400) files = os.listdir("C:\GIS Info\Test\Backup") for xfile in files: if os.path.isfile( "C:\GIS Info\Test\Backup" + xfile ): t = os.stat( "C:\GIS Info\Test\Backup" + xfile ) c = t.st_ctime # delete file if older than a week if c < cutoff: os.remove("C:\GIS Info\Test\Backup" + xfile)
This is the code I was trying to use that got me the furthest.