#!/bin/bash

# Iterate through all PNM files in the current directory
for pnm_file in *.pnm; do
    # Check if the file exists
    if [ -e "$pnm_file" ]; then
        # Construct the corresponding PNG filename
        png_file="${pnm_file%.pnm}.png"

        # Convert PNM to PNG using pnm2png
        pnm2png "$pnm_file" "$png_file"

        # Check if conversion was successful
        if [ $? -eq 0 ]; then
            echo "Conversion successful: $pnm_file -> $png_file"
        else
            echo "Error converting: $pnm_file"
        fi
    fi
done
