Converts All JPG files to PNG files in Linux

#!/bin/bash

# This script converts all JPG files in the current directory to PNG files
cd /path/jpg

for file in *.jpg *.JPG *.jpeg; do
  # Check if the file exists
  if [ -e "$file" ]; then
    # Replace the file extension with .png
    new_file="${file%.jpg}"
    new_file="${new_file%.JPG}.png"

    # Convert the JPG file to a PNG file
    convert "$file" "$new_file"

    # Print the conversion status
    echo "Converted $file to $new_file"
  fi
done

Tags:

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.