Much simpler than scripting vim from the bash command line is to use vimscript from inside of vim (or perhaps a much simpler one-liner for scripting vim from the command line). I personally prefer using the arg list for all multi-file manipulation. For example:
:args ~/src/myproject/**/*.ttl | argdo execute "normal gg=G" | update
argssets the arglist, using wildcards (**will match the current directory as well as subdirectories)|lets us run multiple commands on one lineargdoruns the following commands on each arg (it will swallow up the second|)executepreventsnormalfrom swallowing up the next pipe.normalruns the following normal mode commands (what you were working with in the first place)updateis like:w, but only saves when the buffer is modified.
This :args ... | argdo ... | update pattern is very useful for any sort of project wide file manipulation (e.g. search and replace via %s/foo/bar/ge or setting uniform fileformat or fileencoding).
(other people prefer a similar pattern using the buffer list and :bufdo, but with the arg list I don’t need to worry about closing current buffers or opening up new vim session.)