Help with the FOR command, get current iteration number
Posted: 17 Jun 2010 21:55
Hello!
I am trying to write a little batch file to process video files with ffmpeg.
I would like to be able to know the progress of the process, ie "Processing file 2 of 23". Below is the code I have so far, but all I get in the window tittle is... "Processing file 0 of 23". I can't get the value of %currentfile% to change while the for is running.
Any suggestions?
Thanks in advance
I am trying to write a little batch file to process video files with ffmpeg.
I would like to be able to know the progress of the process, ie "Processing file 2 of 23". Below is the code I have so far, but all I get in the window tittle is... "Processing file 0 of 23". I can't get the value of %currentfile% to change while the for is running.
Any suggestions?
Thanks in advance
Code: Select all
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
Set extensionList= *.mpg *.mov *.wmv *.avi
Set ffmpegParameters= -vcodec flv -b 250k -t 30
SET currentfile=0
for /f "tokens=1* delims=." %%i in ('dir /b %extensionList%') do (
SET /A "currentfile+=1"
CALL:setTitle "Processing file %currentfile% of %filecount%"
ffmpeg.exe -i "%%i.%%j" %ffmpegParameters% -y "%%i_sm.flv"
)
:countFiles -- Counts the number of files that match the extension list
SET filecount=0
for /f "tokens=* delims=" %%i in ('dir /b %extensionList%') do (
SET /A "filecount+=1"
)
EXIT /b
:setTitle title -- Changes window title
:: -- title [string] - Title to show
TITLE %~1
EXIT /b