Skip to content

Instantly share code, notes, and snippets.

@finoradin
Created July 24, 2013 19:48
Show Gist options
  • Save finoradin/6073891 to your computer and use it in GitHub Desktop.
Save finoradin/6073891 to your computer and use it in GitHub Desktop.
make a bunch of bags at once
#!/usr/bin/env python
import bagit, argparse, os
parser = argparse.ArgumentParser(description="Helper for converting a bunch of dirs into bags.")
parser.add_argument('-i', '--input', type=str, required=True, help='The full path to the target dir.')
args = parser.parse_args()
for directory in os.listdir(args.input):
if os.path.isdir(os.path.join(args.input, directory)):
thisdir = os.path.normpath(args.input)+'/'+directory
print thisdir
bagit.make_bag(thisdir, {'Bagged by': 'Ben Fino-Radin'})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment