Created
April 10, 2024 19:12
-
-
Save rudSarkar/8486066b1094fe1785cea64a2034a9fe to your computer and use it in GitHub Desktop.
This file contains 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 | |
# Specify the directory containing CR2 files | |
input_dir="." | |
# Check if the directory exists | |
if [ ! -d "$input_dir" ]; then | |
echo "Directory '$input_dir' does not exist." | |
exit 1 | |
fi | |
# Loop through CR2 files in the directory | |
for cr2_file in "$input_dir"/*.CR2; do | |
# Check if there are CR2 files | |
if [ -e "$cr2_file" ]; then | |
# Get the file name without extension | |
filename=$(basename -- "$cr2_file") | |
filename_no_extension="${filename%.*}" | |
# Convert CR2 file to PNG | |
output_file="$input_dir/$filename_no_extension.png" | |
sips -s format png "$cr2_file" --out "$output_file" | |
# Check if conversion successful | |
if [ $? -eq 0 ]; then | |
echo "Conversion successful: $cr2_file -> $output_file" | |
else | |
echo "Conversion failed for: $cr2_file" | |
fi | |
else | |
echo "No CR2 files found in '$input_dir'." | |
exit 1 | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment