> But I don't really see why my last suggestion "wont work" ..
> If it *doesn't* work, something is just likely slightly off..

It's more on my side not beeing a script guru.. :) but got it working 
(I'm sure it can be done differently, more efficient, well it works...)

> if [ -n "`ls incoming/`" ]; then
>  for srcrpm in incoming/*; do
>    echo $srcrpm | grep -qi 'crw$'
>    if [ $? -gt 0 ]; then
>      echo "erasing $i"
>      rm -f $srcrpm
>    elif [ -f $srcrpm -a -z "`lsof $srcrpm 2>/dev/null`" ]; then
>      echo -n "$srcrpm "
>      ...
>    fi
>  done
> fi

Ok, got it. The script looks now like this. Thanks everyone.


#! /bin/bash
# Extract the jpeg preview from Canon digital EOS RAW data.
# run with "-d" for endless loop.
# Requires dcraw from Dave Coffin
# http://www.cybercom.net/%7Edcoffin/dcraw/

# Settings
WORKDIR=/extra/Temp/Rawimages
INPUT=input
RAWOUT=raw
JPEGOUT=jpeg
NOIMAGE=noimage

# Test for workdir
if [ ! -d $WORKDIR ] ; then
    echo "Workdir: $WORKDIR not found"
    exit 0
fi

# Conversion
convertimages()
{
    # Create dirs in workdir if not exist (or deleted)
    for i in $INPUT $RAWOUT $JPEGOUT $NOIMAGE
    do
        if [ ! -d $WORKDIR/$i ] ; then
            mkdir $WORKDIR/$i
            chmod 770 $WORKDIR/$i
            chown root:users $WORKDIR/$i
        fi
    done

    if [ -n "`ls $WORKDIR/$INPUT/`" ]; then

        # Extract jpeg from RAW in .crw and .CRW files
        for rawimage in $WORKDIR/$INPUT/*.{crw,CRW}; do
            if [ -f $rawimage -a -z "`lsof $rawimage 2>/dev/null`" ]; then
                filename=`basename $rawimage`
                dcraw -e -c $rawimage > $WORKDIR/$JPEGOUT/$filename.jpg
                chmod 660 $WORKDIR/$JPEGOUT/$filename.jpg
                chown root:users $WORKDIR/$JPEGOUT/$filename.jpg
                mv $rawimage $WORKDIR/$RAWOUT/$filename
            fi
        done

        # Move non-RAW files to $NOIMAGE
        for noimage in $WORKDIR/$INPUT/*; do
            if [ -f $noimage -a -z "`lsof $noimage 2>/dev/null`" ]; then
                echo $noimage | grep -qi '.crw$'
                if [ $? -gt 0 ]; then
                    mv $noimage $WORKDIR/$NOIMAGE/`basename $noimage`
                fi
            fi
        done

    fi
}

# Test for loop running
if [ "$1" == "-d" ] ; then
    while :
    do
        convertimages
        sleep 3
    done
else
    convertimages
fi


--
Ariën Huisken


_______________________________________________
tsl-discuss mailing list
[email protected]
http://lists.trustix.org/mailman/listinfo/tsl-discuss

Reply via email to