import ospath="F:\\path_to_modify\\"for file in os.listdir(path): if os.path.isfile(os.path.join(path,file)): new_name=file.replace("OLD_SUBSTRING","NEW_SUBSTRING") os.rename(os.path.join(path,file),os.path.join(path,new_name))print ("complete!")