from glob import glob import os pre = "xyz_" [os.rename(f, "{}{}".format(pre, f)) for f in glob("*.html")]