Created
September 19, 2019 01:46
-
-
Save serverwentdown/bf706632a051d0aa939346e8f3bb43aa to your computer and use it in GitHub Desktop.
A bash script to normalise course documents.
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 | |
for file in */*; do | |
if ! [[ -f $file ]]; then | |
continue | |
fi | |
updated="$(echo $file | sed -E 's~^(([^/]*/)*)(ICT(-CSC)?[0-9]{4})?([- _]*)([^/]+)$~\1\6~')" | |
updated="$(echo $updated | sed -E 's~Chpt ?~Lect~')" | |
updated="$(echo $updated | sed -E 's~L(ecture|ect|ec|0)[- _]*0*([0-9]+)[- _]+~Lec\2 - ~')" | |
updated="$(echo $updated | sed -E 's~Lab[- _]*0*([0-9]+)[- _]+~Lab\1 - ~')" | |
updated="$(echo $updated | sed -E 's~W[- _]*0*([0-9]+)[- _]+~Week\1 - ~')" | |
updated="$(echo $updated | sed -E 's~Tut(orial)?[- _]*0*([0-9]+)[- _]+~Tut\2 - ~')" | |
updated="$(echo $updated | sed -E 's~2019[- _]*~~')" | |
echo "mv '$file' '$updated'" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment