import os

def rename_images(directory=None, prefix="Photo", start_number=1):
    """
    Rename all images in the specified directory to have a sequential name
    starting with a given prefix and followed by a number, regardless of their current names.
    This function assumes all images need to be renamed and does not check for existing naming conventions.
    
    Parameters:
        directory (str): The path to the directory containing the images. Defaults to the current directory.
        prefix (str): The prefix to use for renamed files.
        start_number (int): The starting number for renaming files.
    """
    if directory is None:
        directory = os.getcwd()  # Get the current working directory

    # Get a list of all files in the directory
    files = os.listdir(directory)
    
    # Filter out files to only include common image formats
    image_files = [f for f in files if f.lower().endswith(('.png', '.jpg', '.jpeg', '.gif', '.bmp'))]
    
    # Sort files for consistent ordering (optional)
    image_files.sort()

    # Temporary rename all files to avoid conflicts during renaming
    temp_prefix = "temp_rename_"
    for filename in image_files:
        old_file = os.path.join(directory, filename)
        temp_file = os.path.join(directory, f"{temp_prefix}{filename}")
        os.rename(old_file, temp_file)
    
    # Fetch the temporarily renamed files
    temp_files = [f for f in os.listdir(directory) if f.startswith(temp_prefix)]
    temp_files.sort()

    # Rename files with new naming convention
    for index, filename in enumerate(temp_files, start=start_number):
        # Extract the file extension from the original file
        ext = os.path.splitext(filename)[1]
        
        # Define the new file name
        new_filename = f"{prefix}{index}{ext}"
        
        # Define the full old and new file paths
        old_file = os.path.join(directory, filename)
        new_file = os.path.join(directory, new_filename)
        
        # Rename the file
        os.rename(old_file, new_file)
        print(f"Renamed {filename} to {new_filename}")

# Example usage
rename_images()
