Skip to content

Instantly share code, notes, and snippets.

@pita5
Created February 21, 2012 12:25
Show Gist options
  • Save pita5/1876216 to your computer and use it in GitHub Desktop.
Save pita5/1876216 to your computer and use it in GitHub Desktop.
def self.clean
Dir.entries('images').select do |entry|
if File.directory? File.join('images',entry) and !(entry =='.' || entry == '..')
cleaned_folder_path = File.join('image', entry.split(" ")[0])
File.rename(File.expand_path(entry, 'images'), File.expand_path(cleaned_folder_path))
# Dir.entries(cleaned_folder_path) do |file|
# puts file
# end
end
end
end
# unless File.file? File.join(cleaned_folder_path,file) and (entry.include? =='png' || entry.include? == 'jpeg' || entry.include? == 'jpg' || entry.include? == 'gif')
# File.delete File.expand_path(cleaned_folder_path)
# end
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment