I'm trying to create a batch script for trimming 25 seconds from the beginning of all mp4 files in a folder. The batch script is located in the same folder as the files, and there is a folder called trimmed
in the same folder. This is my script so far:
@echo off
setlocal DisableDelayedExpansion
:promptdel
set /p delorig=Delete original file (default no)? [Y/N]:
if not defined delorig (
set delorig=N
)
set "vartwo="&for /f "delims=YNyn" %%i in ("%delorig%") do set vartwo=%%i
if defined vartwo (
echo Please state Y or N!
goto :promptdel
)
for %%a in ("*.mp4") do (
echo Starting %%a
rem "Need to rename since file names may contain whitespaces"
ren "%%a" "working.mp4"
ffmpeg -loglevel panic -hide_banner -i "working.mp4" -ss 00:00:25.000 -c:v copy -c:a copy "trimmed\%%a"
ren "working.mp4" "%%a"
echo %delorig%
if %delorig% == "Y" (del "%%a" /f /q)
if %delorig% == "y" (del "%%a" /f /q)
echo %%a finished!
)
pause
My problem is that the original file does not get removed regardless of if I input y/Y or n/N. What am I doing wrong?