Skip to content

Instantly share code, notes, and snippets.

@nishalkulkarni
Created September 1, 2021 15:13
Show Gist options
  • Save nishalkulkarni/782d5f32c81af844a3fbc0c9bf33fd99 to your computer and use it in GitHub Desktop.
Save nishalkulkarni/782d5f32c81af844a3fbc0c9bf33fd99 to your computer and use it in GitHub Desktop.
# chmod +x course_unzip.sh
# sudo cp course_unzip.sh /usr/bin/course_unzip
# course_unzip <<archive_name.zip>> <<extract_folder_name>>
mkdir -p $2
unzip -qq $1 -d $2
for entry in "$2"/*
do
newname="$(echo ${entry} |sed -e 's/.*Reference_Material_I*_//')" ;
month="$(echo ${newname} | grep -oP -- '-.*-2' | sed -e 's/-//; s/-2//')" ;
mkdir -p "$2/$month"
echo "$2/$month/$newname"
mv "$entry" "$2/$month/$newname"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment