Inspired by User:Steevcs script to download missing tiles for BSGPSPDA I also wrote a script to redownload old tiles. It only looks at the modified time of the file. Would probably be even better if asking the server if there are a newer tile.
#!/usr/bin/env python """ Author: Jonas Svensson Program: Update OSM tiles Date: 2007-10-14 Description: Walks a directory structure and redownloads any files found that are older than two days. For now everything runs from the current directory Also depends on the directry structure being quite correct: current_directory/zoomlevel/tile_column/tile_number e.g. 13/4090/2709.png """ import urllib import os import time baseurl = "http://dev.openstreetmap.org/~ojw/Tiles/tile.php/" cat = os.listdir(os.getcwd()) for zoomlevel in cat: if os.path.isdir(zoomlevel): columns = os.listdir(zoomlevel) for col in columns: coldir = zoomlevel+os.path.sep+col if os.path.isdir(coldir): filenames = os.listdir(coldir) for filename in filenames: fullfilename = coldir + os.path.sep + filename if os.path.isfile(fullfilename): fileage = time.time() - os.stat(fullfilename).st_mtime if fileage > 2*24*60*60: geturl = baseurl+fullfilename urllib.urlretrieve(geturl, fullfilename) print "Downloaded tile " + fullfilename