Created
January 12, 2022 11:49
-
-
Save TonyWhite/3878891fc2bea4ce009a9fe4e6d3874c to your computer and use it in GitHub Desktop.
Bulk convert HEIC images to Jpeg
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # OBJECTIVE | |
| # Bulk convert HEIC images to Jpeg | |
| # DEPENDENCIES | |
| # imagemagick | |
| # USAGE | |
| # 1) Put script in same folder of HEIC files | |
| # 2) Run the script | |
| # Lists HEIC files (case insensitive) | |
| FILES=(`ls -1 | grep -i ".HEIC"`) | |
| echo "Found ${#FILES[@]} HEIC files" | |
| # Make output dir | |
| mkdir -p "HEIC_to_JPG" | |
| # Process all files | |
| for ((INDEX=0 ; INDEX < ${#FILES[@]}; INDEX++)); do | |
| # Print human readable index | |
| HUMAN_INDEX=$((${INDEX} + 1)) | |
| printf "Convert $HUMAN_INDEX of ${#FILES[@]}..." | |
| # Convert the file to output dir | |
| convert "${FILES[$INDEX]}" "HEIC_to_JPG/$(echo ${FILES[$INDEX]} | cut -f1 -d '.').jpg" | |
| # Print "OK" if OK | |
| if [[ "$?" == "0" ]]; then | |
| echo "OK" | |
| else | |
| echo "ERROR on ${FILES[$INDEX]}" | |
| fi | |
| done | |
| # Print... THE LAST MESSAGE! | |
| echo "Job finished" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment