[Digikam-users] Nikon NEF (RAW) images in Digikam

Dennis Meulensteen dennis at meulensteen.nl
Thu Dec 8 10:55:15 GMT 2005


Nigel Gilbert wrote:
> Hi,
>
>   I'd very much like to have a look at the script you use for converting
> the NEF files. That might just solve my problem.
>
>   Thanks in advance,
>     -Nige
>
>   

Saving the lines below (starting with #!/bin/bash) as filename.sh will 
allow you to make a link to it on your desktop, or wherever. The program 
can be started by the command line 'bash /path/to/filename.sh 
/path/to/directory'.

Although I use it on my own digital photographs, this software is stil 
under development and should be used at your own risk! Always make 
backups first.

Regards,
Dennis.


/#!/bin/bash/
/# recurse through directory tree and process all unprocessed nef files/
/# v. 2.00 (c) Dennis meulensteen, 2005./

*fnListDir ()* *{*
/#Recurse through dir and all its subdirs only acting on files/
	*cd* "$1"	
	
	*for* item *in* *
	*do*
		*if** [* -d "$item"* ]* 	/#check if this item is a directory/
		*then*
			*echo* "Directory: $item"
			fnListDir "$item" /#recurse into the directory/
		*else* 
			/#echo "File: $item"/
			fnEvaluate "*`**pwd**`*/$item"
		*fi*

	*done*
	*cd* ..

*}*

*fnEvaluate ()* *{*
/# Finds out what to do based on the extension of the file and the dir it is in/

	FPATH=${1%/*} /# get: /tmp/my.dir (like dirname)/
	FILE=${1##*/} /# get: filename.tar.gz (like basename)/
	BASE=${FILE%%.*} /# get: filename /
	EXT=${FILE#*.} /# get: tar.gz/
	DIRTYPE=${FPATH##*/} /# get: the containing directory/

	*if** [* "$EXT" == "nef"* ]* *||** [* "$EXT" == "NEF"* ]*
	*then*	
		*if** [* "$DIRTYPE" == "nef"* ]* *||** [* "$DIRTYPE" == "NEF"* ]*
		*then*
			/#echo "Skip processed NEF" /
			*if** [* ! -f "../$BASE.jpg" * ]* 
			*then*
				*echo* "REFRESHING MISSING jpeg Preview Image"
				fnDoConversion "$FPATH" "$FPATH/../$BASE.jpg" "$1"
			*fi*

		*else*
			*echo* "FOUND UNPROCESSED FILE $FPATH/$FILE"
			fnProcessNef "$FPATH" "$FILE" "$BASE"
		*fi*
	/#else/
	/#	echo "Found Other file!!"/
	*fi*
*}*

*fnProcessNef ()* *{*
/# Takes a file and:/
/# places it in the appropriate subdir, /
/# then generates preview image/
	*cd* "$1"

	*if** [* ! -d "$1"/nef* ]* /# if there is no directory for the file to be moved to.../
	*then*
		*echo* "Making new nef directory: $1/nef"
		*mkdir* "$1/nef" /# make one/
	*fi*
	*mv* "$1/$2" "$1/nef/$2" /#put it in there!/
	fnDoConversion "$1" "$1/$3.jpg" "$1/nef/$2" 
*}*

*fnDoConversion ()* *{*
/#Params: out path, output file, input file/
	ufraw-batch --shrink=4 --out-type=jpeg --interpolation=bilinear --out-path="$1" --output="$2" --overwrite "$3"

*}*

/##############################################################/
/# MAIN/
/# recurse through the dir looking for files to be processed/
fnListDir "$1"

*exit* 0


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/digikam-users/attachments/20051208/8d80da60/attachment.html>


More information about the Digikam-users mailing list