Importing .jpeg and Raw files without duplicates

I’m migrating from Lightroom to Darktable, and I’m trying to adapt myself to the new workflow.
For most of my work I use to shoot on Raw and jpeg with my camera, getting two files from each shot. And sometimes, when shooting personal and less important stuff, I turn of Raw image saving and keep only the jpeg.

So now I have a folder on my camera with a bunch of jpeg files with the corresponding Raw files, and some jpeg files alone.

On Lightroom, when importing the whole thing, it will automatically ignore the jpeg files that have the corresponding Raw, and keep the jpeg that doesn’t. So I get in the Catalog ALL the shots, keeping just the “better” file available from each one (the Raw file).

Now, on Darktable, I find that importing the whole flder with the images, it will import both files from the shots that I have Raw and jpeg. And checking the “ignore jpeg” box, it will miss the shots that doesn’t have the Raw together…

Anyone knows how to fix it and make it to work like Lightroom?

By the way, I’m using Darktable 3.0.1 on Linux Mint 19.3.

1 Like

I don’t think there’s any way to do this within darktable. I have a shell script I run against my photos before I import them into darktable - one of the things it does is copy any ‘spare’ jpeg files to a subdirectory so they aren’t imported.

1 Like

Thanks @elstoc. That would be a solution too…
Is that scrip something you can share here? Or maybe can you share how to make one by myself?

Something like the following would do it, assuming your raws all have an extension .CR2 and your jpegs all have an extension .JPG. If you run this from within the directory containing your photos it should only copy those jpegs that have an associated raw into the subidrectory “spareJpegs”. I haven’t tested it (I’m away from my main computer at the moment) so back up first.

#!/bin/bash

mkdir -p spareJpegs
for file in *.CR2 
do
   baseFile=$(basename "$file" .CR2)
   mv "$baseFile.JPG" spareJpegs
done

Thanks a lot @elstoc !!! It run smoothly!
Plus, I’m learning how to write scripts for Linux (I’m new on that too).

So, I just open the terminal in the folder with the pictures and copy/paste the commands you shared, and it worked beautifully!

Now I’m figuring out how to make it more “ready to use”. I copy/paste the same commands on a text editor and saved it as “spareJpegs.sh”, so I can just move the script file into the folder with the pictures and run it, and it will do its job.

I’m wondering if there is a more intelligent way of running the script in each folder without having to copy/paste or move the “spareJpegs.sh” into each folder every time.
Is there maybe a way to save it somewhere else and access it from the pictures folder?

I know I’m probably out of the topic here already, and that it’s not directly related with DarkTable, but once we are already talking about that, maybe it will help others with the same question.

Yes. Once you’ve created the shell script you can run it from where you like. I have my script (along with others) in my $HOME/bin directory. You can either type the full path of the shell script from whatever directory you’re in e.g. $HOME/bin/myscript.sh or (better) you can add $HOME/bin to your $PATH and then you just need to type myscript.sh.

I’ve given you some pointers (and perhaps terms you’re not familiar with) but best you find a good shell scripting tutorial online (there are plenty) and work your way through it. It’s a very powerful way of doing little jobs like that.

BTW while you may name the file how you like, the .sh extension is not necessary in Linux. The #!/bin/bash line at the top tells Linux what sort of file it is. You just need to change its permissions and make it executable (chmod +x myscript).

There’s a lua script for darktable that does exactly what you want. I am on my cell phone so I cannot look how it’s named but it’s in the official lua repository.

It’s here:

You need both and it will give you an additional drop-down in import dialog to prefer raw over jpeg.

2 Likes