Skip to content

Instantly share code, notes, and snippets.

@srosenthal
Created December 17, 2017 20:40
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save srosenthal/3adc0dafcdd3c55656bad7a4a8de9c91 to your computer and use it in GitHub Desktop.
Save srosenthal/3adc0dafcdd3c55656bad7a4a8de9c91 to your computer and use it in GitHub Desktop.
Batch convert HEIC (iPhone) photos to JPEG, preserving creation dates
for i in *.heic; do sips -s format jpeg -s formatOptions best "${i}" --out "${i%heic}jpg" && touch -r "${i}" "${i%heic}jpg"; done
@benwoodward
Copy link

Thanks.

I had to tweak it a bit to get it to work (it was outputting '.HEICjpg' as file ext. and not finding .HEIC files (because iOS outputs uppercase file extensions for photos):

for i in *.HEIC; do sips -s format jpeg -s formatOptions best "${i}" --out "${i%heic}.jpg" && touch -r "${i}" "${i%heic}.jpg"; done

@tlh24
Copy link

tlh24 commented Dec 30, 2020

Or, with imageMagick: for i in *.HEIC; do convert "${i}" "${i%heic}.jpg" && touch -r "${i}" "${i%heic}.jpg"; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment