batch file enabledelayedexpansion and exclamation marks

Associate
Joined
18 Oct 2002
Posts
886
Location
UK
I have managed to put together a batch file that i can drag and drop video files into and then it creates a report for each file showing if there is any corruption.

It works great except for when a file contains an exclamation mark and then it randomly breaks. I have been mass renaming videos to remove all exclamation marks, but it would be nice to know how to get this working properly. The batch file:

Code:
@echo off
setlocal enabledelayedexpansion

set argCount=0
for %%x in (%*) do (
   set /A argCount+=1
   set "argVec[!argCount!]=%%~x"
)

echo Number of processed arguments: %argCount%
for /L %%i in (1,1,%argCount%) do (
TITLE %%i/%argCount%
echo !argVec[%%i]!
"<path to ffmpeg>\ffmpeg.exe" -v error -i "!argVec[%%i]!" -f null - >"!argVec[%%i]!".log 2>&1
)
pause

I presume the !argCount! is where the issue is, but im not very familiar with batch files. I have tried changing the "!" to other special characters, but it seems to require exclamation marks.

Any help is greatly appreciated.
 
Back
Top Bottom