Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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