This turned out to be quite easy:
replace 'old text' 'new text' files-to-replace
So for example to change all spaces to underscores in a folder of jpegs, you can cd to the folder and type
replace ' ' '_' *.jpg
I did see some other syntax for this online which looked more like sed, so maybe it depends on the linux distribution (I was using Red Hat at the time).