import subprocess import os # path to the folder containing the images folder_path = "/mnt/c/Users/eric/Desktop/FSEG/DPOS/" # loop through all files in the folder for filename in os.listdir(folder_path): # check if the file is a .gif image # construct the full path to the image file image_path = os.path.join(folder_path, filename) # construct the new file name, replacing .gif with .jpg new_filename = os.path.splitext(filename)[0] + ".jpg" new_image_path = os.path.join(folder_path, new_filename) # call the convert command from ImageMagick subprocess.run(["convert", image_path, new_image_path])