I have a little batch file (see below) that does what the REM statement says.
When executed it displays each filename in turn as it's being processed (with a progress bar (of sorts) as the file is 're-written' to disk) but I would also like it to display a "counter" (starting at 1) that increments with each file processed so that when the final file is processed the counter will then display the total number of files that have been processed.
Is there any simple change I could make to achieve this? (I am not a coder, the batch file was given to me by someone else with whom I have lost contact.)
REM --ooOO This adds c.365ms silence to all mp4 video files in the folder (adding 364 bytes to file size) OOoo--
for %%a in (*.mp4) do mp4box "%%a" -add 0.2sSilenceM.mp3
pause
CodePudding user response:
To implement a counter is quite easy:
setlocal enabledelayedexpansion
set counter=0
for %%a in (*.mp4) do (
set /a counter =1
echo processing file !counter!: %%a
mp4box "%%a" -add 0.2sSilenceM.mp3
)
echo total processed files: %counter%
You need delayed expansion to use the counter inside the loop.