import glob, os, string files = glob.glob("*.pyw") for item in files: os.rename(item, string.strip(item, ".pyw") + ".py")