The loop pattern behind most of these examples: process each matching file into out/, keeping the base name, and speak a notification on macOS when the batch finishes, so long renders can run unattended.

Swap in any command from the other examples as the loop body.

The command

shopt -s nullglob nocaseglob
mkdir -p out

for f in *.mp4; do
  name="${f%.*}"
  echo "$name"
  ffmpeg -nostdin -i "$f" \
    -c copy -movflags +faststart \
    "out/${name}.mp4"
done

command -v say >/dev/null && say "Process complete"

What each part does

shopt -s nullglob      no matches → no iterations (instead of a literal
                       "*.mp4")
shopt -s nocaseglob    *.mp4 also matches .MP4 (camera files)
mkdir -p out           write results to a separate folder, so outputs
                       aren't picked up as inputs and inputs aren't
                       overwritten
"${f%.*}"              file name without its extension
ffmpeg -nostdin        keep ffmpeg from reading the terminal, which
                       otherwise can swallow input meant for the loop
say                    macOS text-to-speech (skipped where unavailable)

When to use it

The loop the other batch scripts are built on: it runs one ffmpeg command over every .mp4 in the current folder, writes each result to out/ under the same base name, and speaks "Process complete" on macOS when the batch finishes. Use it for long unattended renders where you only need to know when it's done. The default body is a stream-copy faststart remux, like ../conversion/remux-faststart.sh.

It's not the right tool for files in subfolders, since the glob only matches the current folder. It also doesn't fit when each file needs different settings.

To adapt it, swap the ffmpeg line for a command from another example and change *.mp4 or the out/${name}.mp4 extension to match. The header explains each flag. standardize-batch.sh and render-visualizer-set.sh are worked examples of this.

If the output looks wrong:

  • Nothing happens: run it from inside the folder that holds the videos. With no matching files, the loop silently does nothing.
  • No announcement: say only exists on macOS and is skipped elsewhere.

Notes

Source
the loops in ffmpeg-utilities (batch.sh, batch 2.sh, faststart.sh, overlay.sh, …)
Changed
name=`echo "${i%.*}"` → name="${f%.*}"; added nullglob, nocaseglob, mkdir -p and -nostdin; say -v Alex → say (the Alex voice isn't installed by default on current macOS)