def getFileNameWithNewExtension(input_file, format):
    """
    Takes an input_file name and applies new extension to it by:
    (i) replacing initial extension if there is one, OR
    (ii) just appending new extension.
    """
    base_name = input_file
    last_four = base_name[-4:]
    found = last_four.find(".")
    if found > -1:
        idx = len(base_name) + found
        base_name = base_name[:idx]
    return base_name + "." + format