Forked from anonymous/files_from_one_should_be_in_other.rb
Created
January 28, 2016 22:54
-
-
Save rdp/d706df3c4e87ff93a398 to your computer and use it in GitHub Desktop.
This file contains 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
if ARGV.length != 2 | |
puts "syntax: dir_that_has_files_that_should_be_duplicated dir_that_should_have_those_files" | |
exit 1 | |
end | |
def all_files_in_dir dir | |
all_in = {} | |
Dir[File.expand_path(dir) + "/**/*"].each{|f| # need expand path or in windows Dir["a\b/*"] failz <sigh> | |
if File.file? f | |
filename = File.basename(f) | |
file_size = File.size(f) | |
key = "#{filename}_#{file_size}" # XX md5? | |
all_in[key] ||= [] # accomodate duplicates | |
all_in[key] << File.expand_path(f) | |
end | |
} | |
all_in | |
end | |
files_wanted = all_files_in_dir(ARGV[0]) | |
files_there = all_files_in_dir(ARGV[1]) | |
p "searching for #{files_wanted.length} files among #{files_there.length}..." | |
desired_but_not_found = files_wanted.keys - files_there.keys | |
for bad in desired_but_not_found | |
puts "unable to find #{bad} #{files_wanted[bad]} anywhere" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment