Skip to content

Instantly share code, notes, and snippets.

@rietta
Created October 2, 2013 04:31
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 rietta/6789184 to your computer and use it in GitHub Desktop.
Save rietta/6789184 to your computer and use it in GitHub Desktop.
Usage: arcdir /PATH It tarball ALL subdirectories under the and moves the originals to the Trash First, install these from homebrew: brew install trash brew install pigz
#!/usr/bin/env bash
# Archive all of the children directories of a directory into compressed tar files
# and prepare a text file that lists all of the files in each archive.
# Therefore, for directories foo ane bar, produce
# foo.tar.bz2, foo.tar.txt, bar.tar.bz2, and bar.tar.txt.
###
# The trash command is OS X specific ane requires a 3rd party tool -
# brew install trash
# brew install pigz
###
if [ -d "$1" ]; then
cd "$1"
for f in */; do
if [ -d "$f" ]; then
echo "Compressing and preparing a file listing $f..."
tar --use-compress-program=pbzip2 -cf "${f%/}.tar.bz2" "$f" && tar -jtvf "${f%/}.tar.bz2" > "${f%/}.tar.txt" && trash "$f"
fi
done
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment