ffmpeg – how to Encode multiple video files in multiple folders

how to encode multiple video files (different types)
in one main folder with multiple subfolders
to h265 with new name?

so i found this:

@echo off
set "_x=compressed"

for /r %%i in (*.mkv, *.mp4, *.mov) do ffmpeg -i "%%~fi" -vcodec libx265 -crf 24  "%%~dpni%_x%.mp4"`

BUT, this command also encode the first processed file again,
from
original.mkv
to
original_compressed
and again to:
original_compressedcompressed

how to avoid this? to run each file found whatever it is mkv or mp4 or avi only once?

Read more here: Source link