Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Irostovsky/5e0e41c4396acf1df7e78493beccd93c to your computer and use it in GitHub Desktop.
Save Irostovsky/5e0e41c4396acf1df7e78493beccd93c to your computer and use it in GitHub Desktop.
Delete unused images
Dir["app/assets/images/*"].each do |image|
name = File.basename(image)
if Dir.glob("**/*").reject {|fn| File.directory?(fn) }.
map{|fn| File.read(fn).include?(name) ? fn : nil }.any?
p image
else
p "To delete: #{image}"
File.delete image
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment