while getopts vf: opt ; do
case "$opt" in
v) echo "verbose set" ;;
f) echo "f: $OPTARG" ;;
\\?) echo "Error: unknown flag" >&2 ;;
shift `expr $OPTIND - 1`
Basically, you run "getopts" giving it a "parameter string" and a variable name. The parameter string is a list of letters you want to pull arguments from and each one that takes an argument itself is followed by a colon (:).
Loop through the arguments as above, and then use "shift" and the "OPTIND" to shift off all the arguments that were processed, leaving only the "regular" arguments, e.g. take out all the "-v" and such but leave the list of file names.