return to first page linux journal archive
keywordscontents
#!/usr/local/bin/python
#

print
print "Removing old ~*.tmp"
print

import os
import time
import stat

def ScanDir( level ) :
     files = os.listdir( os.curdir )
     for p in files :
          if os.path.isdir( p ) :
               if p != os.curdir and p != os.pardir :
                    os.chdir( p )
                    ScanDir( level + 1 )
          else :
               if p[ 0 ] == '~' and p[-4:] == '.tmp':
		    if (time.time() - os.stat( p ) [
stat.ST_MTIME ]) ><\n> 
(3600*24) :
                         print '%12s - %9d bytes - %-s'% (p, os.stat( p )[ 
stat.ST_SIZE ], os.getcwd())
                          os.unlink( p )
     if level > 0 :
         os.chdir( os.pardir )

#
# Execution starts here
#
c os.getcwd()
os.chdir( '/' )
ScanDir( 0 )
os.chdir( c )