Skip to content

Instantly share code, notes, and snippets.

@cjweeg
Created December 20, 2011 20:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cjweeg/1503142 to your computer and use it in GitHub Desktop.
Save cjweeg/1503142 to your computer and use it in GitHub Desktop.
Looks through a "BagIt" Missing-Files-manifest and locates lines where the string "._" does not occur
#!/usr/bin/env ruby
# ARGV[0] should point to the directory where the "BagIt" text file is stored
if !ARGV[0]
puts "You must specify the directory \"BagIt\" text file is stored. Try again!"
exit
end
# first we find the full path of the argument in case we're only given
# a partial path.
bagit_file_path = File.expand_path(ARGV[0])
# we check to make sure that the specified directory actually exist
if !File.exist?(bagit_file_path)
puts "\"BagIt\" directory does not exist. Try again!"
exit
end
error_counter = 0
error_lines = (File.open(bagit_file_path, "r")).each do |line|
if !line.include?("._")
puts line
error_counter += 1
end
end
puts "Error count = " + error_counter.to_s
#!/usr/bin/env ruby
# ARGV[0] should point to the directory where the "BagIt" text file is stored
if !ARGV[0]
puts "You must specify the directory where \"BagIt\" text file is stored. Try again!"
exit
end
# first we find the full path of the argument in case we're only given
# a partial path.
bagit_file_path = File.expand_path(ARGV[0])
# we check to make sure that the specified directory actually exist
if !File.exist?(bagit_file_path)
puts "\"BagIt\" directory does not exist. Try again!"
exit
end
missing_file_counter = 0
missing_file_lines = (File.open(bagit_file_path, "r")).each do |line|
if !line.include?("._")
puts line
missing_file_counter += 1
end
end
puts "Missing files count = " + missing_file_counter.to_s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment