This script will convert all HEIC files in the current directory to JPEG files.
- The
libheif-examples
command must be installed.
If you are on a Linux system, you can install the libheif-examples
command by running the following command:
sudo apt install libheif-examples
If you are on a macOS system, you can install the libheif-examples
command by running the following command:
brew install libheif-examples
Once you have installed the libheif-examples
command, you can run this command by pasting it into the terminal.
for file in *.heic; do heif-convert -q 92 $file ${file/%.heic/.jpg}; done
Here is a breakdown of the command line:
for
- This keyword starts afor
loop.file
- This variable is used to iterate over the files in the current directory.in
- This keyword is used to specify the range of files that thefor
loop will iterate over. In this case, the*.heic
pattern matches all files that end in.heic
.do
- This keyword marks the start of the code that will be executed for each file in the loop.heif-convert
- This command is used to convert HEIC files to other formats.-q
- This option specifies the quality of the output JPEG file.92
- This value specifies a quality of 92%, which is a good balance between quality and file size.$file
- This variable is used to reference the current file in the loop.${file/%.heic/.jpg}
- This part of the line replaces the.heic
extension of the current file with.jpg
.done
- This keyword marks the end of thefor
loop.
The script will create a new JPEG file for each HEIC file in the current directory. The new JPEG files will have the same name as the original HEIC files, but with the .jpg
extension.
I sincerely hope this documentation is useful. Please let me know if you have any other questions.