Skip to content

Instantly share code, notes, and snippets.

@mrmcwake
Forked from bittercoder/convert.sh
Last active August 25, 2022 05:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrmcwake/6d22eee12e8261e75743019c9219f4bc to your computer and use it in GitHub Desktop.
Save mrmcwake/6d22eee12e8261e75743019c9219f4bc to your computer and use it in GitHub Desktop.
Recursively converts .heic files to .jpg on linux for a specified root directory (coming from an iOS11 device over USB)
#!/bin/bash
# Recursively converts all HEIC files to JPG for the specified directory. Skips any files that have already
# been converted. Requires tifig, download latest release from github:
# https://github.com/monostream/tifig/releases and install at /usr/bin/tifig
# (or add the install location you choose to your $PATH)
#
# usage: ./heicToJpg.sh [RootDirectory]
#
rootDir=$1
if [ -z "$rootDir" ]
then
echo "Need to specify root directory."
exit 1
fi
find $rootDir -type f -iname "*.heic" | while read f
do
n=$(echo $f | sed 's/.heic/.JPG/I')
if [ -f $n ]; then
echo "Alredy converted. Skipping $f"
continue
fi
echo "Converting $f"
tifig -i "$f" -o "$n"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment