Skip to content

Instantly share code, notes, and snippets.

@edsu
Last active April 18, 2024 19:57
Show Gist options
  • Save edsu/edc19d99299b734fa1b29ce18919a723 to your computer and use it in GitHub Desktop.
Save edsu/edc19d99299b734fa1b29ce18919a723 to your computer and use it in GitHub Desktop.
Remembering the original spirit of BagIt. https://twitter.com/justin_littman/status/778561421428793344
#!/bin/bash
#
# The simplest way to create a valid BagIt bag?
#
# Usage: bagit.sh <dir_to_bag> <bag_dir>
#
# Note: you'll need to have md5deep installed:
# brew install md5deep
# apt-get install md5deep
# etc...
#
source_dir=$1
bag_dir=$2
mkdir -p $bag_dir/data
cp -a $source_dir $bag_dir/data
cd $bag_dir
md5deep -lr data > manifest-md5.txt
echo "BagIt-Version: 0.97" > bagit.txt
echo "Tag-File-Character-Encoding: UTF-8" >> bagit.txt
today=`date +%Y-%m-%d`
echo "Bagging-Date: $today" > bag-info.txt
echo "External-Description: This bag was created by $USER on $today." >> bag-info.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment