Created
February 20, 2013 17:25
-
-
Save johndel/4997293 to your computer and use it in GitHub Desktop.
Image cleanup script
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
# encoding: utf-8 | |
require "fileutils" | |
img=Dir.glob("**/*.jpeg")+Dir.glob("**/*.jpg")+Dir.glob("**/*.png")+Dir.glob("**/*.gif") | |
data=Dir.glob("**/*.htm*")+Dir.glob("**/*.css*")+Dir.glob("**/*.js*") | |
puts img.length.to_s+" images found & "+data.length.to_s+" files found to search against" | |
content="" | |
data.each do |f| | |
content+=File.open(f, 'r').read | |
end | |
content.encode!('UTF-8', 'UTF-8', :invalid => :replace) | |
#File.open("text.txt", 'w') { |file| file.write(content) } | |
img.each do |m| | |
if not content=~ Regexp.new("\\b"+File.basename(m)+"\\b") | |
puts "Image "+m+" not found anywhere in html, css, js" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment