How do I batch convert thousands of NEFs to JPEGs?

One solution, on Ubuntu, would be to use dcraw to convert NEF to PBM, and pnmtopng to convert PBM to png. So, open a terminal and run these commands:

sudo apt-get install netpbm dcraw

I don't have any .NEF images to test this, but according to this page, you can do:

Convert all NEF images to PNG:

dcraw -c -w input.NEF | pnmtopng > output.png

To convert an entire directory:

for filename in *.NEF ; do dcraw -c -w "$filename" | pnmtopng > "$filename.png" ; done

Probably the best tool around for all your batch image processing needs, however, is ImageMagick. It's free, open source, cross platform and can do just about everything you can think of including resizing, cropping, managing transparancy, montage and converting between most image formats under the sun. It would have been my first choice, but I found some (older) posts claiming that it did not work with NEF. Still, their website says it does, so you should try it out and in any case, it is really worth learning. Install it on Ubuntu with:

sudo apt-get install imagemagick

To convert a single .NEF:

convert foo.NEF foo.jpg

To convert all .NEF files in the current directory (will overwrite the originals):

mogrify -format jpg *.NEF

To do the same but keeping the original files, run convert in a loop:

for img in *.NEF; do convert "$img" "$img.jpg"; done

If you do end up using ImageMagick, then I recommend using xargs if you've actually got thousands of images to convert rather than using a for loop. That way, you can easily bump up the parallelism:

# Runs these conversions serially
ls *.NEF | sed 's#.NEF##' | xargs -I^ convert ^.NEF ^.jpg

# Runs these conversions with 8 different processes
ls *.NEF | sed 's#.NEF##' | xargs -P8 -I^ convert ^.NEF ^.jpg

Another great free tool is IrfanView that when combined with plugins can Batch convert from almost any format to JPG.

Q: Can I use IrfanView on Linux?

A: Yes. There is no native-Linux version of IrfanView. However, you can use IrfanView in conjunction with Linux programs like WINE, Windows Linux emulators and Linux-based virtual machines. Take the ZIP version of IrfanView and unzip it or copy your existing Windows IrfanView folder to Linux. This is easier because the installer may need additional Windows DLLs to run.

If you want a software that is more OS independent then I would recommend UFRaw. Use it either on its own or in conjunction with Gimp