Last active
December 10, 2015 21:28
-
-
Save akshaye/4494960 to your computer and use it in GitHub Desktop.
ruby code snippet i wrote to delete duplicate files from music folder
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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