bin/cleanse

23 lines
595 B
Plaintext
Raw Normal View History

2010-08-02 11:14:18 -04:00
#!/usr/bin/python
#
# by Erik osheim
import optparse, os
epilog = 'Remove various junky files left lying around.'
patterns = ('*~', '.#*', '#*', '*.orig', '*-')
parser = optparse.OptionParser(epilog=epilog)
parser.add_option('-f', '--fake', dest='fake', action='store_true',
help="print files; do not remove them")
opts, args = parser.parse_args()
stanzas = ' -o '.join(["-name '%s'" % x for x in patterns])
cmd = "find . -type f \\( %s \\) -print" % stanzas
if opts.fake:
print "files that would be deleted:"
else:
cmd += " -exec rm {} ';'";
os.system(cmd)