import sys from os import rename, path, listdir ext = ".c01" cwd = "." # Check if there is an argument on the command line and use it as the target folder if len(sys.argv) > 1: cwd = sys.argv[1] # Retrieve the file list from the defined/default working directory files = listdir(cwd) for fname in files: # Check if the file has the required extension (ext) if fname.lower().endswith(ext): print("Rename file " + fname + " to " + fname.upper()) rename(path.join(cwd, fname), path.join(cwd, fname.upper()))