Skip to content

Instantly share code, notes, and snippets.

@bramus
Last active Aug 20, 2018
Embed
What would you like to do?
Toledo/Blackboard Gradebook Unzipper, Unix Style.
# toledounzip
# usage: toledounzip gradebook_B-KSL-JLW323-1314_LABO04\ \(LW6\ -\ LW7\).zip
function toledounzipmain() {
if (( $# != 1 )); then
echo "Please provide the name of a .zip file generated by Toledo";
else
if [ ! -f "$1" ]; then
echo "Invalid filename";
else
echo "=== Start unzipping main zip “$1”";
unzip "$1" > /dev/null;
rm "$1";
echo "=== Done unzipping main zip “$1”";
echo "=== Start unzipping single zips";
toledounzipsingles;
echo "=== Done unzipping single zips";
fi
fi
}
function toledounzipsingles() {
for filename in *.txt; do NAME=$(head -n 1 "$filename" | sed 's/Naam: //g'); BASENAME=$(echo $filename | sed 's/.txt//g'); find . -type f -name "$BASENAME*.zip" -exec echo "- unzipping single “{}” by $NAME" \; -exec mkdir "$NAME" \; -exec tar -xzf "{}" --exclude="*__MACOSX*" --exclude="*.DS_Store" -C "$NAME" \; -exec rm "{}" \; -exec rm "$BASENAME.txt" \;; done;
}
alias toledounzip="toledounzipmain"
@bramus
Copy link
Author

bramus commented Apr 24, 2014

Add this to your .bash_profile or .bashrc
Usage: toledounzip gradebook_B-KSL-JLW323-1314_LABO04\ \(LW6\ -\ LW7\).zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment