For those people who are mac noobs like me, to create and run the above script:
1. Open TextEdit,
2. Put the editor into Plain Text mode - Format > Make Plain Text.
(If you skip this step, it will not let you save it as a script.)
3. Paste the above script into the TextEdit window
4. Save the file as a script - File > Save As in TextEdit. Enter your filename followed by the “.sh” file extension, and then Save the document to the Desktop.
5. Open the Terminal application
6. Navigate to the desktop in Terminal - Type in (then press enter):
7. Set the permissions for the file you just created so you can run it - Type in Terminal (then press en):
sudo chmod 700 file.sh
(Replace "file.sh" with the name of your script.)
8. Run the file - Type in Terminal:
(Again, replace "file.sh" with the name of your script.)
9. Open Notifications in System Preferences. You should be able to find the Spotify App and turn off the notifications.
Source for creating a script: Terminal 101: Automate the Terminal with Bash Scripts