Skip to content

Instantly share code, notes, and snippets.

@jronallo
Forked from cjweeg/gist:1501794
Created December 20, 2011 15:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jronallo/1502041 to your computer and use it in GitHub Desktop.
Save jronallo/1502041 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
if !ARGV[0] or !ARGV[1]
puts "You must specify the raw and enhanced directories. Try again!"
exit
end
# first we find the full path of the arguments in case we're only given
# partial paths.
raw_input_file_path = File.expand_path(ARGV[0])
enhanced_input_file_path = File.expand_path(ARGV[1])
# next we'll join the raw input file path with the asterisk, find all the
# filepaths, and then map the filepath to file base names.
enhanced_files = Dir.glob(File.join(raw_input_file_path, '*')).map do |filepath|
File.basename(filepath)
end
raw_files = Dir.glob(File.join(enhanced_input_file_path, '*')).map do |filepath|
File.basename(filepath)
end
# now we calculate if there are any unique files
enhanced_dir_unique_files = raw_files - enhanced_files
raw_dir_unique_files = enhanced_files - raw_files
# I haven't checked whether this will work for all cases
if raw_dir_unique_files.count == 0 and enhanced_dir_unique_files.count == 0
puts "No unique files in either directory"
elsif raw_dir_unique_files.count >= 1 and enhanced_dir_unique_files.count == 0
puts "One or more unique files exist in the RAW directory"
puts raw_dir_unique_files
elsif raw_dir_unique_files.count == 0 and enhanced_dir_unique_files.count >= 1
puts "One or more unique files exist in the ENHANCED directory"
puts enhanced_dir_unique_files
elsif raw_dir_unique_files.count >= 1 and enhanced_dir_unique_files.count >= 1
puts "One or more unique files exist in the EACH directory"
puts "RAW"
puts raw_dir_unique_files
puts "ENHANCED"
puts enhanced_dir_unique_files
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment