Last active
February 16, 2022 21:48
-
-
Save megawertz/fddca130cac4a5041b8461bf86603f5e to your computer and use it in GitHub Desktop.
Basic script to unzip and configure downloaded assignment zip bundles from Blackboard. Makes it easy to get to grading quicker by organizing the directory a bit. The cleanandprep.sh file makes it easier to prep multiple downloaded bundles at once.
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
#!/bin/bash | |
# Original student zip files go here after processing | |
DONEDIR="_done" | |
# Make sure we have a file to process and directory to go to | |
if [ $# -ne 2 ]; then | |
echo "Requires 2 Arguments: INPUT_FILE MAIN_OUTPUT_DIR" | |
exit | |
fi | |
# Pass in input file and output director as script options | |
# Config this to use proper options? | |
MAINOUTPUTDIR=${2} | |
INPUTFILE=${1} | |
# Unzip main BB file and move into that directory | |
unzip -q $INPUTFILE -d $MAINOUTPUTDIR | |
cd $MAINOUTPUTDIR | |
mkdir $DONEDIR | |
OIFS="${IFS}" | |
IFS=$'\n' | |
# Currently configured to use the unar tool so it can easily | |
# process multiple formats of compressed files. | |
for file in $(ls -1 *.{zip,rar,7z}); | |
# for file in *.zip; | |
do | |
USERNAME=$(echo ${file} | awk -F'[_]' '{print $2}') | |
unar -q -o "$USERNAME" "${file}" | |
# unzip "${file}" -d "$USERNAME" | |
# Move corresponding .txt file into the recently unzipped directory | |
COMMENTS=$(ls *${USERNAME}*.txt) | |
mv "${COMMENTS}" "${USERNAME}/" | |
# Move the zip folder to the done directory in case needed | |
mv "${file}" "${DONEDIR}"/ | |
done | |
IFS="${OIFS}" |
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
for i in *.zip | |
do | |
ASST=$(echo "${i}" | awk -F'[_]' '{print $3"_"$4}' | awk -F'[-]' '{print $1}') | |
ASST=$(echo ${ASST%??}) | |
echo "File: ${i}" | |
echo "Modified: ${ASST}" | |
mv ${i} "${ASST}.zip" | |
/home/jason/bin/bbgradeprep "${ASST}.zip" ${ASST} | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
like that it can handle all types of compression - always have one person who uses 7z !