1) Try using delayed expansion for your variables:
setlocal enabledelayedexpansion
2) Verify if some extension (%~x1) was provided in argument:
if /i "%~x1"=="" (set "_filtro=.mp4") else set "_filtro=%~x1"
3) Use For /F and Where.exe /R loop command, where you can recursively list/process your files:
for /f "tokens=* delims= " %%i in ('%__APPDIR__%where.exe /r . "*!_filtro!"'
4) Take advantage of the operator ||, for to rename any file that has an error:
"!_ffmpeg!" -i "%%~i" -v error -f null - || ren "%%~i" "%%~ni_ERROR_%%~xi"
5) Use Clip command for copy your log file content to your ClipBoard/Crtl+C:
type .\error.log|"%__APPDIR__%clip.exe"
6) If you prefer, you can also replace Pause to Timeout.exe, and/or, exit /b to goto :EOF:
"%__APPDIR__%timeout.exe" /t -1 & endlocal & goto :EOF
@echo off && setlocal enabledelayedexpansion
echo\ & cd/d "%~dp0" && >nul cd.>.\error.log
set "_ffmpeg=F:\- error check\ffmpeg.exe"
if /i "%~x1"=="" (set "_filtro=.mp4") else set "_filtro=%~x1"
echo\Filtro: ..\*!_filtro! && for /f "tokens=* delims= " %%i in ('%__APPDIR__%where.exe /r . "*!_filtro!"'
)do echo\%%~i && 2>>error.log ("!_ffmpeg!" -i "%%~i" -v error -f null - || ren "%%~i" "%%~ni_ERROR_%%~xi")
type error.log | "%__APPDIR__%clip.exe" & "%__APPDIR__%timeout.exe" /t -1 & endlocal & goto :EOF
- Same code in compacted formatting:
@echo off && setlocal enabledelayedexpansion && echo\ & cd/d "%~dp0" & >nul cd.>.\error.log
set "_ffmpeg=F:\- error check\ffmpeg.exe" && if /i "%~x1"=="" (set "_filtro=.mp4") else set "_filtro=%~x1"
echo\Filtro: ..\*!_filtro! && for /f "tokens=* delims= " %%i in ('%__APPDIR__%where.exe /r . "*!_filtro!"'
)do echo\%%~i && 2>>error.log ("!_ffmpeg!" -i "%%~i" -v error -f null - || ren "%%~i" "%%~ni_ERROR_%%~xi")
echo/ && type .\error.log|"%__APPDIR__%clip.exe" & "%__APPDIR__%timeout.exe" /t -1 & endlocal & goto :EOF
For command line help, you can use /?:
Ren /?, For /?,Where /?, Endlocal /?, Goto /?, Timeout /?, SetLocal /?, if /?
On the internet, you can get more help on: