Batch convert NEF (raw) to PNG

Here is a simple script for converting raw NEF files from a Nikon to PNG format. It uses the convert utility which can handle a large variety of file types and has various options for the conversion. This is just a simple script that will generate a PNG that is either 1024 px wide or high.

#!/bin/bash
##################################
#      Convert files to png      #
##################################

files=`ls ./`;
if [ ! -d png ] 
then
	mkdir png;
fi

for file in $files
do
	in=./$file;
	out=./${file%.*}".png";
	if [ ! -f $out ] 
	then
		echo "converting $file";
		convert "$in" -resize 1024x1024 "$out" ;
		mv $out png/;
	fi
done

The script will create a folder in the directory its run in and process all the files saving the converted PNG into the created folder.