Created
October 2, 2013 04:31
-
-
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
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 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