Created
July 24, 2018 04:49
-
-
Save sunmockyang/f2457ce488b5311d8dcb713b808abb6e to your computer and use it in GitHub Desktop.
Quickly find differences between two folders that should be the same
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
| # 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