Skip to content

Instantly share code, notes, and snippets.

@akshaye
Last active December 10, 2015 21:28
Show Gist options
  • Save akshaye/4494960 to your computer and use it in GitHub Desktop.
Save akshaye/4494960 to your computer and use it in GitHub Desktop.
ruby code snippet i wrote to delete duplicate files from music folder
Dir.chdir('/Users/akshay/Music')
dupFiles = File.join('**', '* 2.mp3')
Dir.glob(dupFiles).each do |dup|
puts "duplicate file: #{dup}"
if File.exists?(dup)
orig = dup[0..-2]
puts "original file: #{orig}"
if File.exists?(orig)
if File.size(dup) == File.size(orig)
puts "deleting #{dup}"
File.delete(dup)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment