I have a directory whose files have extension either .JPG or .NEF and I want to delete the files of the form X.NEF for which X.JPG does not exist in the directory. (X here can be any string.) I don't know how to do this other than by hand.
A more general situation is when you want to find all the files in a directory A which exist in directory B as well. (The first problem can be turned into the second one using