Skip to content

Commit

Permalink
Deal with _products_ of NEF files, and prefer JPG to NEF
Browse files Browse the repository at this point in the history
  • Loading branch information
odinho committed Aug 18, 2016
1 parent 00437e4 commit fcb09ae
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions import_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,19 @@ def handle(self):

added_entries = []
for new_filename in sorted(files, reverse=True):
# More than one file with the same name but different
# extension?
fn, ext = os.path.splitext(new_filename)
if ext.lower() != '.nef':
if any(fn + ext in files for ext in ['.nef', '.NEF']):
# Skip the non-nef file
print "skip", fn, ext
continue
if fn.lower().endswith('.nef'):
# If the file name *without the extensions* ends with .nef,
# we are probably dealing with some product of the nef.
# Either the .nef.xmp, or the extracted .nef.jpg.
# Let's just ignore it.
continue
if ext.lower() == '.nef' and fn + '.jpg' in files:
# If we're a nef file, and we have a similar named
# jpg in the same place. We'll prefer the jpg, because
# it might be a processed raw image.
print "Skipping {}, found jpeg candidate.".format(new_filename)
continue
path = os.path.join(folder_path, new_filename.decode('utf8'))
second_exception = False

Expand Down

0 comments on commit fcb09ae

Please sign in to comment.