Created
December 20, 2011 20:31
-
-
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
This file contains 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
#!/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 |
This file contains 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
#!/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