[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: batch RAW converters



2008/12/3 Bob <spam@homeurl.co.uk>:
> some time ago when I was mostly a widows user I wrote a nice little batch
> script that took as an argument a directory path in-which it expected to
> find a ./RAW directory containing the *.CRW raw files from my old canon
> camera, then it used dcraw and exiftool to develop the raw file and copy the
> exif meta data over to the new file.
>
> This can probably be done with a one liner under linux, can someone help me
> convert the functionality of this to an sh or perl script?
>
> Thank you, the windows batch is below.
> ##################################
>
> @echo off
> cls
> echo from CRW raws
> %~d1
> cd\
> cd %~p1
> cd RAW
> dir /B *.CRW > raw.txt
> copy C:\raw_converters\.badpixels ..\
> :: @echo on
>
> set Sufix1=tiff
> ::
>
> FOR /f %%a in (raw.txt) do call :de_raw %%a
> GOTO SUB_DONE :de_raw
> :: cd ..
> IF EXIST "..\%~n1.%Sufix1%" GOTO :EOF echo use dcraw to convert %~nx1 to
> "%~n1.%Sufix1%"
> C:\raw_converters\dcraw.exe -T -v -w -B 2 4 "%~n1.CRW" ::
> C:\raw_converters\dcraw.exe -T -v -w -K "C:\raw_converters\dark.pgm"
> "%~n1.CRW" :: worst for some reason
> ::
> echo use exiftool to copy all meta data from %~nx1 to "%~n1.%Sufix1%"
> C:\raw_converters\exiftool.exe -TagsFromFile "%~n1.CRW" "%~n1.%Sufix1%"
> ::
> ::
> echo del "%~n1.%Sufix1%_original"
> del "%~n1.%Sufix1%_original"
> echo move "%~n1.%Sufix1%" to ..\
> move "%~n1.%Sufix1%" ..\
> :: cd RAW
> GOTO :EOF :SUB_DONE
> del raw.txt
> del ..\.badpixels
> :: http://www.sno.phy.queensu.ca/~phil/exiftool/exiftool_pod.html
> ::
>
>
> --
> To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject
> of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
>

hey hey,
  Here's a skeleton to get you started, at least something to work with.
  I don't work with crw/raw and haven't seen a .bat script in a
while... but this should help
  If you have questions about the linux vs windows differences just ask!

cheers,
Owen.

###################################

#!/bin/bash

RAWDIR="$1"
BADPIXELS="/home/bob/.badpixels"
INSUFFIX="CRW"
OUTSUFFIX="tiff"

DCRAW="/usr/bin/dcraw"
EXIFTOOL="/usr/bin/exiftool"

usage() {
  echo "Usage: $0 <dir>"
  exit 1;
}

do_dcraw(){
  ## N.B. the -B option doesn't seem to exist in the version I checked...
  ${DCRAW} -T -v -w -B 2 4 "$1"
}

do_exiftool(){
  ${EXIFTOOL} -TagsFromFile "$1" "$2"
}

do_convert() {
  local FILENAME="$1"
  local BASENAME=`basename ${FILENAME} .${INSUFFIX}`
  do_dcraw ${FILENAME}
  do_exiftool ${FILENAME} ${BASENAME}.${OUTSUFFIX}
}

## A quick argument check
if ( [ $# -ne 1 ] || # Only one argument
  [ ! -d $1 ] ) # The argument exists and is a directory
  then usage
fi

## Crawl the given dir and do the actual conversion
find $RAWDIR -name "*.${INSUFFIX}" -execdir do_convert '{}' \;

exit 0;


Reply to: