Created
June 26, 2017 11:30
-
-
Save Irostovsky/5e0e41c4396acf1df7e78493beccd93c to your computer and use it in GitHub Desktop.
Delete unused images
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["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