Last active
August 20, 2018 09:00
-
-
Save bramus/11254137 to your computer and use it in GitHub Desktop.
Toledo/Blackboard Gradebook Unzipper, Unix Style.
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
# 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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this to your
.bash_profile
or.bashrc
Usage:
toledounzip gradebook_B-KSL-JLW323-1314_LABO04\ \(LW6\ -\ LW7\).zip