Skip to content

Instantly share code, notes, and snippets.

@muaazsaleem
Created February 26, 2020 14:40
Show Gist options
  • Save muaazsaleem/dc8d7d4ff28d85f89e2fe04f91383a18 to your computer and use it in GitHub Desktop.
Save muaazsaleem/dc8d7d4ff28d85f89e2fe04f91383a18 to your computer and use it in GitHub Desktop.
Batch convert images from png to jpg on a mac
#!/bin/bash
PNG_PATH=~/Desktop
shopt -s nullglob
png_files=($PNG_PATH/*.png)
shopt -u nullglob
for pfile in "${png_files[@]}"; do
jfile="${pfile%.png}.jpg"
echo "converting $pfile to $jfile"
sips -s format jpeg "$pfile" --out "$jfile"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment