This provides a basic framework for a bash script, with argument parsing and various other handling of the commandline. It also provides a few useful functions for the script.
To use, copy and replace the actual functioning code at the bottom.
While there are two different command argument parsers, and they warn you to only use one, if you leave them both in place, your script will work fine... but you'll be confused later when you come back to edit your script a year later.