Skip to content

Instantly share code, notes, and snippets.

@edsu
Last active January 8, 2019 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edsu/013c0d0d10e989f1af72e9790d0cf5cf to your computer and use it in GitHub Desktop.
Save edsu/013c0d0d10e989f1af72e9790d0cf5cf to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
"""
usage: batch_validate.py <bags directory>
"""
import os
import sys
import bagit
bags_dir = sys.argv[1]
for bag_dir in os.listdir(bags_dir):
try:
bag_path = os.path.join(bags_dir, bag_dir)
bag = bagit.Bag(bag_path)
bag.validate()
print("{} is valid".format(bag_dir))
except bagit.BagError as e:
print("{} is invalid: {}".format(bag_dir, e))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment