<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Nigel Gilbert wrote:
<blockquote cite="mid1134035320.19524.46.camel@maltbury3.norbnet.org"
type="cite">
<pre wrap="">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
</pre>
</blockquote>
<br>
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'. <br>
<br>
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.<br>
<br>
Regards,<br>
Dennis.<br>
<br>
<br>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="Generator" content="Kate, the KDE Advanced Text Editor">
<pre><span style="color: rgb(128, 128, 128);"><i>#!/bin/bash</i></span>
<span style="color: rgb(128, 128, 128);"><i># recurse through directory tree and process all unprocessed nef files</i></span>
<span style="color: rgb(128, 128, 128);"><i># v. 2.00 (c) Dennis meulensteen, 2005.</i></span>
<span style="color: rgb(255, 0, 255);"><b>fnListDir ()</b></span> <b>{</b>
<span style="color: rgb(128, 128, 128);"><i>#Recurse through dir and all its subdirs only acting on files</i></span>
<span
style="color: rgb(136, 0, 136);"><b>cd</b></span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">"</span>
<b>for</b> item <b>in</b> *
<b>do</b>
<b>if</b><span
style="color: rgb(136, 0, 136);"><b> [</b></span> -d <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$item</span><span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(136, 0, 136);"><b> ]</b></span> <span
style="color: rgb(128, 128, 128);"><i>#check if this item is a directory</i></span>
<b>then</b>
<span
style="color: rgb(136, 0, 136);"><b>echo</b></span> <span
style="color: rgb(221, 0, 0);">"Directory: </span><span
style="color: rgb(0, 128, 0);">$item</span><span
style="color: rgb(221, 0, 0);">"</span>
fnListDir <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$item</span><span
style="color: rgb(221, 0, 0);">"</span> <span
style="color: rgb(128, 128, 128);"><i>#recurse into the directory</i></span>
<b>else</b>
<span
style="color: rgb(128, 128, 128);"><i>#echo "File: $item"</i></span>
fnEvaluate <span
style="color: rgb(221, 0, 0);">"</span><b>`</b><span
style="color: rgb(136, 0, 136);"><b>pwd</b></span><b>`</b><span
style="color: rgb(221, 0, 0);">/</span><span
style="color: rgb(0, 128, 0);">$item</span><span
style="color: rgb(221, 0, 0);">"</span>
<b>fi</b>
<b>done</b>
<span
style="color: rgb(136, 0, 136);"><b>cd</b></span> ..
<b>}</b>
<span style="color: rgb(255, 0, 255);"><b>fnEvaluate ()</b></span> <b>{</b>
<span style="color: rgb(128, 128, 128);"><i># Finds out what to do based on the extension of the file and the dir it is in</i></span>
<span
style="color: rgb(0, 128, 0);">FPATH=${1%/*}</span> <span
style="color: rgb(128, 128, 128);"><i># get: /tmp/my.dir (like dirname)</i></span>
<span
style="color: rgb(0, 128, 0);">FILE=${1##*/}</span> <span
style="color: rgb(128, 128, 128);"><i># get: filename.tar.gz (like basename)</i></span>
<span
style="color: rgb(0, 128, 0);">BASE=${FILE%%.*}</span> <span
style="color: rgb(128, 128, 128);"><i># get: filename </i></span>
<span
style="color: rgb(0, 128, 0);">EXT=${FILE#*.}</span> <span
style="color: rgb(128, 128, 128);"><i># get: tar.gz</i></span>
<span
style="color: rgb(0, 128, 0);">DIRTYPE=${FPATH##*/}</span> <span
style="color: rgb(128, 128, 128);"><i># get: the containing directory</i></span>
<b>if</b><span
style="color: rgb(136, 0, 136);"><b> [</b></span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$EXT</span><span
style="color: rgb(221, 0, 0);">"</span> == <span
style="color: rgb(221, 0, 0);">"nef"</span><span
style="color: rgb(136, 0, 136);"><b> ]</b></span> <b>||</b><span
style="color: rgb(136, 0, 136);"><b> [</b></span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$EXT</span><span
style="color: rgb(221, 0, 0);">"</span> == <span
style="color: rgb(221, 0, 0);">"NEF"</span><span
style="color: rgb(136, 0, 136);"><b> ]</b></span>
<b>then</b>
<b>if</b><span
style="color: rgb(136, 0, 136);"><b> [</b></span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$DIRTYPE</span><span
style="color: rgb(221, 0, 0);">"</span> == <span
style="color: rgb(221, 0, 0);">"nef"</span><span
style="color: rgb(136, 0, 136);"><b> ]</b></span> <b>||</b><span
style="color: rgb(136, 0, 136);"><b> [</b></span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$DIRTYPE</span><span
style="color: rgb(221, 0, 0);">"</span> == <span
style="color: rgb(221, 0, 0);">"NEF"</span><span
style="color: rgb(136, 0, 136);"><b> ]</b></span>
<b>then</b>
<span
style="color: rgb(128, 128, 128);"><i>#echo "Skip processed NEF" </i></span>
<b>if</b><span
style="color: rgb(136, 0, 136);"><b> [</b></span> ! -f <span
style="color: rgb(221, 0, 0);">"../</span><span
style="color: rgb(0, 128, 0);">$BASE</span><span
style="color: rgb(221, 0, 0);">.jpg"</span> <span
style="color: rgb(136, 0, 136);"><b> ]</b></span>
<b>then</b>
<span
style="color: rgb(136, 0, 136);"><b>echo</b></span> <span
style="color: rgb(221, 0, 0);">"REFRESHING MISSING jpeg Preview Image"</span>
fnDoConversion <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$FPATH</span><span
style="color: rgb(221, 0, 0);">"</span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$FPATH</span><span
style="color: rgb(221, 0, 0);">/../</span><span
style="color: rgb(0, 128, 0);">$BASE</span><span
style="color: rgb(221, 0, 0);">.jpg"</span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">"</span>
<b>fi</b>
<b>else</b>
<span
style="color: rgb(136, 0, 136);"><b>echo</b></span> <span
style="color: rgb(221, 0, 0);">"FOUND UNPROCESSED FILE </span><span
style="color: rgb(0, 128, 0);">$FPATH</span><span
style="color: rgb(221, 0, 0);">/</span><span
style="color: rgb(0, 128, 0);">$FILE</span><span
style="color: rgb(221, 0, 0);">"</span>
fnProcessNef <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$FPATH</span><span
style="color: rgb(221, 0, 0);">"</span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$FILE</span><span
style="color: rgb(221, 0, 0);">"</span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$BASE</span><span
style="color: rgb(221, 0, 0);">"</span>
<b>fi</b>
<span
style="color: rgb(128, 128, 128);"><i>#else</i></span>
<span
style="color: rgb(128, 128, 128);"><i># echo "Found Other file!!"</i></span>
<b>fi</b>
<b>}</b>
<span style="color: rgb(255, 0, 255);"><b>fnProcessNef ()</b></span> <b>{</b>
<span style="color: rgb(128, 128, 128);"><i># Takes a file and:</i></span>
<span style="color: rgb(128, 128, 128);"><i># places it in the appropriate subdir, </i></span>
<span style="color: rgb(128, 128, 128);"><i># then generates preview image</i></span>
<span
style="color: rgb(136, 0, 136);"><b>cd</b></span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">"</span>
<b>if</b><span
style="color: rgb(136, 0, 136);"><b> [</b></span> ! -d <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">"</span>/nef<span
style="color: rgb(136, 0, 136);"><b> ]</b></span> <span
style="color: rgb(128, 128, 128);"><i># if there is no directory for the file to be moved to...</i></span>
<b>then</b>
<span
style="color: rgb(136, 0, 136);"><b>echo</b></span> <span
style="color: rgb(221, 0, 0);">"Making new nef directory: </span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">/nef"</span>
<span
style="color: rgb(204, 0, 204);"><b>mkdir</b></span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">/nef"</span> <span
style="color: rgb(128, 128, 128);"><i># make one</i></span>
<b>fi</b>
<span
style="color: rgb(204, 0, 204);"><b>mv</b></span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">/</span><span
style="color: rgb(0, 128, 0);">$2</span><span
style="color: rgb(221, 0, 0);">"</span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">/nef/</span><span
style="color: rgb(0, 128, 0);">$2</span><span
style="color: rgb(221, 0, 0);">"</span> <span
style="color: rgb(128, 128, 128);"><i>#put it in there!</i></span>
fnDoConversion <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">"</span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">/</span><span
style="color: rgb(0, 128, 0);">$3</span><span
style="color: rgb(221, 0, 0);">.jpg"</span> <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">/nef/</span><span
style="color: rgb(0, 128, 0);">$2</span><span
style="color: rgb(221, 0, 0);">"</span>
<b>}</b>
<span style="color: rgb(255, 0, 255);"><b>fnDoConversion ()</b></span> <b>{</b>
<span style="color: rgb(128, 128, 128);"><i>#Params: out path, output file, input file</i></span>
ufraw-batch --shrink=4 --out-type=jpeg --interpolation=bilinear --out-path=<span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">"</span> --output=<span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$2</span><span
style="color: rgb(221, 0, 0);">"</span> --overwrite <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$3</span><span
style="color: rgb(221, 0, 0);">"</span>
<b>}</b>
<span style="color: rgb(128, 128, 128);"><i>##############################################################</i></span>
<span style="color: rgb(128, 128, 128);"><i># MAIN</i></span>
<span style="color: rgb(128, 128, 128);"><i># recurse through the dir looking for files to be processed</i></span>
fnListDir <span
style="color: rgb(221, 0, 0);">"</span><span
style="color: rgb(0, 128, 0);">$1</span><span
style="color: rgb(221, 0, 0);">"</span>
<span style="color: rgb(136, 0, 136);"><b>exit</b></span> 0
</pre>
<br>
</body>
</html>