Created
June 10, 2010 18:52
-
-
Save capotej/433453 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env ruby | |
require 'ftools' | |
EXTS = %w{ jpg gif jpeg png } | |
DEST = '/Users/capotej/Pictures' | |
def cleanup?(p) | |
return true unless EXTS.select { |f| p.to_s.include?(f) or p.to_s.include?(f.upcase) }.empty? | |
end | |
Dir["/Users/capotej/Desktop/*"].each do |p| | |
if cleanup?(p) | |
unless File.exists?(DEST + '/' + File.basename(p)) | |
File.move(p, DEST) | |
else | |
new_name = p + ".dup#{rand(123123)}" | |
File.rename(p, new_name) | |
File.move(new_name, DEST) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment