Created
March 12, 2009 20:51
-
-
Save byingyang/78278 to your computer and use it in GitHub Desktop.
Displays the file names of files that are not found in any documents under the given search directories
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
#!/usr/bin/env ruby | |
def unused_images(image_path_dir, search_dirs) | |
img_fns = Dir.glob("#{image_path_dir}**/*.*") | |
search_dirs.each {|sd| img_fns.delete_if{|img_fn| `grep -r '#{File.basename(img_fn)}' #{sd}` != ""}} | |
return img_fns | |
end | |
if ARGV.size < 2 | |
puts "Usage: image_cleanup path_to_images path_to_search ..." | |
exit 1 | |
end | |
image_path = ARGV.shift | |
unused_images(image_path, ARGV).each do |fn| | |
puts fn | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment