Skip to content

Instantly share code, notes, and snippets.

@rjswenson
Created November 18, 2014 03:55
Show Gist options
  • Save rjswenson/3701f26fd055b4dc66d5 to your computer and use it in GitHub Desktop.
Save rjswenson/3701f26fd055b4dc66d5 to your computer and use it in GitHub Desktop.
Remove all image files not matching Product number regex
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