Skip to content

Instantly share code, notes, and snippets.

@ximeg
Last active October 18, 2020 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ximeg/f339be3ccada51f9ab44fb91e31cfd13 to your computer and use it in GitHub Desktop.
Save ximeg/f339be3ccada51f9ab44fb91e31cfd13 to your computer and use it in GitHub Desktop.
Move JPG files that do not have a matching raw file
#!/usr/bin/env python
import os
import shutil
raw_ext = '.RAF'
jpg_ext = '.JPG'
destination = 'jpg_only'
for filename in os.listdir('.'):
(shortname, extension) = os.path.splitext(filename)
if extension == jpg_ext:
if not os.path.isfile(shortname + raw_ext):
if not os.path.isdir(destination):
os.mkdir(destination)
print('Moving ' + shortname + jpg_ext + '...')
shutil.move(shortname + jpg_ext, destination)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment