Skip to content

Instantly share code, notes, and snippets.

@sunmockyang
Created July 24, 2018 04:49
Show Gist options
  • Select an option

  • Save sunmockyang/f2457ce488b5311d8dcb713b808abb6e to your computer and use it in GitHub Desktop.

Select an option

Save sunmockyang/f2457ce488b5311d8dcb713b808abb6e to your computer and use it in GitHub Desktop.
Quickly find differences between two folders that should be the same
# Only compares file names, not the file contents
dir1 = ARGV[0]
dir2 = ARGV[1]
def get_relative_path_of_contents(dir)
return Dir["#{dir}/**/*"].select{|f| File.file?(f)}.map { |e|
e[dir] = ""
e
}
end
all_files_dir1 = get_relative_path_of_contents(dir1)
all_files_dir2 = get_relative_path_of_contents(dir2)
puts "DIRECTORY 1 does not contain:"
puts all_files_dir2.reject { |e| all_files_dir1.include?(e) }
puts "DIRECTORY 2 does not contain:"
puts all_files_dir1.reject { |e| all_files_dir2.include?(e) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment