bin/cleanse

23 lines
596 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:
2020-09-01 09:10:18 -04:00
print("files that would be deleted:")
2010-08-02 11:14:18 -04:00
else:
cmd += " -exec rm {} ';'";
os.system(cmd)