video – Dynamically change a file name when using FFmpeg

I am currently trying to compress all of my video files (anywhere between 30GB and 500GB) and i have found out a way to get the batch file to run it for all of my files in a folder but it keeps giving me back ‘this file already exists overwrite?[y/N]‘ however even if I press yes (i will be deleting the original files anyway) it will not allow me to do so as it cannot write to a file from the same file. I currently have this as my code

@echo off
set 0=compressed
for %%i in (*.mkv, *.mp4, *.mov) do ffmpeg -i "%%i" -vcodec libx265 -crf 24  "%%i%0.mp4"

though when i have %%i.mp4 or %%~ni.mp4 it will not change the output name to anything else. however I need it to

also as a side question how can i get ffmpeg to see subfolders too and not just the folder it is in?

Read more here: Source link