Skip to content

Instantly share code, notes, and snippets.

@jackdpeterson
Last active January 8, 2019 04:35
Show Gist options
  • Save jackdpeterson/eef8b086b2eed16796ac310f66d5b9aa to your computer and use it in GitHub Desktop.
Save jackdpeterson/eef8b086b2eed16796ac310f66d5b9aa to your computer and use it in GitHub Desktop.
bash script to recursively convert RAW to JPEG retaining directory structure.
#!/bin/bash
src_dir=$1
src_dir_length=${#src_dir}
dest_dir=$2
file_type="ARW"
### let's use ufraw-batch. This assumes that you've compiled to the latest ... 0.22 as of this one doesn't cause crappy weirdness with red-spots appearing with under-exposure.
# Usage: ./convert_raw_to_jpeg.sh /source/folder /destination/folder
#
###
if [ ! -d "${src_dir}" ]; then
echo "provided source directory is not a dir"
exit 2
fi
if [ ! -d "${dest_dir}" ]; then
echo "provided destination directory is not a valid directory!"
exit 2
fi
find ${src_dir} . -type f -name "*.${file_type}" | while IFS= read -r src
do
dst=$(echo "${dest_dir}/${src#$src_dir/}")
dst_dir=$(dirname ${dst})
mkdir -p $(dirname "$dst")
cmd=$(echo "ufraw-batch --wb=camera --exposure=auto --out-type=jpeg --compression=100 --exif --rotate=camera --overwrite --out-path=${dst_dir} ${src}")
echo performing ${cmd}
$(${cmd})
done
@lancethepants
Copy link

Sweet utility, thanks for sharing.

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