Sha256: 63d1aa292d5903efd6ed2f5899963f71675a3487dea34322cd77f00a541e2a57
Contents?: true
Size: 883 Bytes
Versions: 27
Compression:
Stored size: 883 Bytes
Contents
#!/usr/bin/env ruby count = 0 used = [] unused = [] Dir["./app/assets/images/**/*"].each do |path| puts "Checking #{path}..." filename = path.split("/").last if filename =~ /(.*)\.(jpg|png|gif)$/ puts "grep #{filename} ./servers/* -R" result = `grep #{filename} ./servers/* -R` print result if result.length < 1 || result =~ /Binary/ puts "Adding #{path} to queue to remove..." unused << path # system "git rm #{path}" count += 1 else used << path end end end puts "Counted #{count} unused files:." unused.each do |file| puts file end if count > 0 puts "Delete these files?" response = gets if response =~ /y/i unused.each do |file| system "git rm #{file}" end else puts "Cancelled." end end puts "The following #{used.size} files were used:" used.each do |file| puts file end
Version data entries
27 entries across 22 versions & 1 rubygems