Following the answers to this post I get the following script:
#!/bin/bash
gs \
-sOutputFile=/tmp/output.pdf \
-sDEVICE=pdfwrite \
-sColorConversionStrategy=Gray \
-sColorConversionStrategyForImages=Gray \
-dProcessColorModel=/DeviceGray \
-dCompatibilityLevel=1.4 \
-dNOPAUSE \
-dBATCH \
$1
mv /tmp/output.pdf $1
However, running identify -verbose file.pdf | grep Colorspace afterwards shows Colorspace: sRGB.
I want to make these true grayscale PDFs, and have the Colorspace be set to gray. I have one PDF that reports gray, but I don't know how to make ghostscript convert the other ones to be like it.