#!/usr/bin/env python3 import os string = ".720p.WEB.h264-ETHEL" # Get the current working directory cwd = os.getcwd() # Get a list of all the files in the current directory files = os.listdir(cwd) # Iterate over the files and rename them for file in files: # Get the old and new names of the file old_name = file new_name = file.replace(string, "") # Rename the file os.rename(old_name, new_name)