Skip to content

Instantly share code, notes, and snippets.

@cnunciato
Created March 23, 2014 21:20
Show Gist options
  • Save cnunciato/9730034 to your computer and use it in GitHub Desktop.
Save cnunciato/9730034 to your computer and use it in GitHub Desktop.
Finds and deletes JPG sidecar files with corresponding DNGs
require 'find'
require 'fileutils'
tested = matched = jpgs = 0
Find.find('/Volumes/Media/Lightroom/') do |path|
if path.match(/\.dng$/i)
jpg_path = path.gsub('.dng', '.jpg')
if File.exists?(jpg_path)
FileUtils.rm(jpg_path)
jpgs += 1
end
matched += 1
end
tested += 1
end
puts "#{tested} files tested, #{matched} DNGs, #{jpgs} JPGs deleted."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment