Extracting Desire to learn (D2L) zip files into student folders

Mon 15 April 2019 by Dr. Dirk Colbry

D2L Logo

At MSU we use Desire to Learn for our classroom content management system. Students can go to D2L to get their assignments and turn in their assignments though the D2L dropbox.

When grading, I can download all of the student's submissions into a zip file such as the following:

Part 1 - Software Evaluation Download Mar 23, 2019 609 AM.zip

HW1 - Matrix Transpose Download Feb 2, 2019 1001 AM.zip

If this folder is unzipped files similar to the following will appear:

323771-372818 - Sam Smith - Jan 21, 2019 652 PM - submission.tgz
325034-372818 - Nan Carpenter - Jan 21, 2019 330 PM - 1d wave eqn.pages
325034-372818 - Nan Carpenter - Jan 21, 2019 330 PM - wave1d.py
331582-372818 - Joe Taylor - Jan 19, 2019 315 PM - HW1.ipynb
331582-372818 - Joe Taylor - Jan 19, 2019 315 PM - HW1_report.pdf
331582-372818 - Joe Taylor - Jan 19, 2019 315 PM - short.mp4
331582-372818 - Joe Taylor - Jan 19, 2019 320 PM - HW1.tgz

For many of the topics we cover (mostly programming) these filenames are not easy to use. In my classes student often submit files that need to work together with given file names (everything after the final dash). I wrote the following program to convert the directory of complex filenames into folders. A separate folder for each student with the files in the folder:

#!/bin/bash
files=`ls`
find . -iname "*" | while read file
do
        echo $file
        folder=`echo $file | cut -d "-" -f 3 | xargs`
        echo "creating folder $folder"
        mkdir -p "$folder"
        newname=`echo $file | cut -d "-" -f5- | xargs`
        echo "Renaming to $newname"
        mv "$file" "./$folder/$newname"
done
Sam Smith
Nan Carpenter
Joe Taylor

Each directory contains that student's files. For example the Joe Taylor folder will have:

HW1.ipynb
HW1_report.pdf
short.mp4
HW1.tgz

I hope you find this script useful.


Comments