Skip to content

Instantly share code, notes, and snippets.

@rafaelp
Last active March 8, 2025 21:36
Show Gist options
  • Save rafaelp/4467738 to your computer and use it in GitHub Desktop.
Save rafaelp/4467738 to your computer and use it in GitHub Desktop.

Revisions

  1. rafaelp revised this gist Jan 6, 2013. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions find_unused_images.rake
    Original file line number Diff line number Diff line change
    @@ -14,5 +14,6 @@ task :find_unused_images do
    end
    end
    end
    puts "\n\nDelete unused files running the command below:"
    puts "rm #{images_to_delete.join(" ")}"
    end
  2. rafaelp revised this gist Jan 6, 2013. 1 changed file with 15 additions and 13 deletions.
    28 changes: 15 additions & 13 deletions find_unused_images.rake
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,18 @@
    # It requires ACK - http://betterthangrep.com/
    task :find_unused_images do
    images = Dir.glob('app/assets/images/**/*')

    images_to_delete = []
    images.each do |image|
    unless File.directory?(image)
    # print "\nChecking #{image}..."
    print "."
    if IO.popen("ack -1 -G '(app|public)' --ruby --html --css --js #{File.basename(image)}").eof?
    images_to_delete << image
    end
    task :find_unused_images do
    images = Dir.glob('app/assets/images/**/*')

    images_to_delete = []
    images.each do |image|
    unless File.directory?(image)
    # print "\nChecking #{image}..."
    print "."
    result = `ack -1 -G '(app|public)' --ruby --html --css --js #{File.basename(image)}`
    if result.empty?
    images_to_delete << image
    else
    end
    end
    puts "rm #{images_to_delete.join(" ")}"
    end
    end
    puts "rm #{images_to_delete.join(" ")}"
    end
  3. rafaelp created this gist Jan 6, 2013.
    16 changes: 16 additions & 0 deletions find_unused_images.rake
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    # It requires ACK - http://betterthangrep.com/
    task :find_unused_images do
    images = Dir.glob('app/assets/images/**/*')

    images_to_delete = []
    images.each do |image|
    unless File.directory?(image)
    # print "\nChecking #{image}..."
    print "."
    if IO.popen("ack -1 -G '(app|public)' --ruby --html --css --js #{File.basename(image)}").eof?
    images_to_delete << image
    end
    end
    end
    puts "rm #{images_to_delete.join(" ")}"
    end