#!/bin/sh for RAW_FILE in `ls -1v --color=never *.CR2`; do JPG_FILE=${RAW_FILE%%.CR2}.JPG if [[ ! -f JPG/$JPG_FILE ]]; then echo Extracting preview from $RAW_FILE to $JPG_FILE with EXIF /usr/bin/exiftool -b -PreviewImage -w JPG/%f.JPG $RAW_FILE /usr/bin/exiftool -tagsfromfile $RAW_FILE --PreviewImage --ThumbnailImage -overwrite_original_in_place -q JPG/$JPG_FILE touch -r $RAW_FILE JPG/$JPG_FILE fi done