#! /bin/bash # Script: FindJpgOlderThanTif.sh # Purpose: This is part of a RAW workflow, where RAW -> TIF -> JPG # If a JPEG file is found that is older than the corresponding TIF, # then something is fishy. # This script offers various actions when a file is found # (default is to open explorer on the inaccurate file). # It assumes you save your RAW, TIF and JPEG in the same location. # Author: Guillaume Dargaud - http://www.gdargaud.net/ # Copyright: (c) 2006 - Free use, distribution and modification # # You need cygwin to run this on Windows: http://www.cygwin.com/ # To launch this from Explorer, create a FindJpgOlderThanTif.bat file with the following: # SET PATH="/usr/local/bin:/usr/bin:/bin" # c:\cygwin\bin\bash FindJpgOlderThanTif.sh # PAUSE ############################################################################### # Pass a DNG/RAW/RAF/whatever file. # It will check for the existence of a TIF and JPG file at the same place # and ensure that the JPEG is newer than the TIF function FindJpgOlderThanTif { if [ $# -ne 1 ]; then exit; fi # Error, even the RAW file doesn't exist !!! # Replace extension. We (wrongly) assume lower case is always use, change accordingly tif="$( echo "$1" | sed -e "s/\.[a-zA-Z0-9]*$/.tif/" )" && jpeg="$( echo "$1" | sed -e "s/\.[a-zA-Z0-9]*$/.jpg/" )" && if [ -f "$tif" -a -f "$jpeg" -a "$tif" -nt "$jpeg" ]; then # Chose one or more of the lines below: # echo $jpeg # Display file name in Linux format cygpath -w "$jpeg" # Display file name in Windows format # rm -i "$jpeg" # Just delete it (with confirmation) # gm convert "$tif" "$jpeg" # Convert it. Warning, this is a basic conversion that will lose the profile cygstart explorer /e,/select,"$(cygpath -w "$jpeg")" read -p "Press [enter] to continue" fi } export -f FindJpgOlderThanTif ############################################################################### # Now let's look under the current directory. Add whatever RAW format you wish here echo "JPEG files which are older than their TIF file:" find \( -iname \*.raf -o -iname \*.dng -o -iname \*.nef -o -iname \*.raw -o -iname \*.crw -o -iname \*.cr2 -o -iname \*.mrw -o -iname \*.orf -o -iname \*.ptx \) -exec bash -c "FindJpgOlderThanTif \"{}\"" \;