Skip to content

Instantly share code, notes, and snippets.

@hyjk2000
Created November 11, 2018 10:19
Show Gist options
  • Select an option

  • Save hyjk2000/4042f8dba1c7aa76a232244959a199c4 to your computer and use it in GitHub Desktop.

Select an option

Save hyjk2000/4042f8dba1c7aa76a232244959a199c4 to your computer and use it in GitHub Desktop.
Remove orphan JPG files which are not accompanied with CR2 files
# requires recycle-bin: https://github.com/sindresorhus/recycle-bin
orphan_files = Dir.glob('*.JPG').reject do |jpg_file|
File.exist? "#{File.basename(jpg_file, '.*')}.CR2"
end
puts "Removing #{orphan_files.size} orphan files: "
orphan_files_join = orphan_files.join(' ')
puts orphan_files_join
exec "recycle-bin #{orphan_files_join}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment