All pastes #1944293 Raw Edit

Mine

public python v1 · immutable
#1944293 ·published 2010-09-19 16:57 UTC
rendered paste body
import os, shutilimport sysimport fnmatchdef locate(pattern, root=os.curdir):    for path, dirs, files in os.walk(os.path.abspath(root)):        for filename in fnmatch.filter(files, pattern):            yield os.path.join(path, filename)if len(sys.argv) == 1:    print "Use: {name} pattern garbage".format(name = sys.argv[0])    print "garbage is the crap you want to strip from filenames"    quit(1)for f in locate(sys.argv[1]):    a, crap, b = f.partition(sys.argv[2])    if not crap:        continue    nf = a + b    try:        shutil.move(f, nf)    except Exception as e:        print "Couldn't move {f} to {nf}: {err}".format(f = f, nf = nf, err = str(e))    else:        print "Moving {f} to {nf}".format(f = f, nf = nf)