Created
November 18, 2014 03:55
-
-
Save rjswenson/3701f26fd055b4dc66d5 to your computer and use it in GitHub Desktop.
Remove all image files not matching Product number regex
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
prod_nums = Product.all.map(&:number).uniq | |
image_files = Dir.entries("data/products") | |
image_files.delete(".") | |
image_files.delete("..") | |
image_files.each do |imf| | |
unless prod_nums.include?(imf.split('_')[0]) | |
File.delete("data/products/#{imf}" | |
print "*" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment