Unable to extract duration info using ffprobe, commas in filenames are messing up my for loop

Solution 1:

I think it has something to do with commas (,) within the part where ffprobe is executed to the file %%v.:

:: adder fails with filenames with ampersand "&". investigate`

Just try add 2>&1 in ffprob command.
Also replace echo string,with &, and commas to:
echo+ & <nul set /p .="Str,ing,s with & and com,mas" >>file

for /f tokens^=* %%v in ('dir "%folder%\%wildcards%" /b /s /a-d 2^>nul')do 2>nul mkdir "c:%%~pv" & if not exist "c:%%~pnxv.txt" (
    for /f usebackq^tokens^=1*delims^=^, %%i in (`2^>^&1 "%ffprobe%" -v quiet -show_entries "format=duration" -of csv "%%v"`)do (
        echo+ & <nul set /p .="%%v/%%j/%%~zv">>"c:%%~pnxv.txt"))

Obs.: About the same thing: 2>nul mkdir folder vs if not exist folder (create)do not do(ignore)...

By using mkdir folder, you can create folder if it does not exist in one action, in an already existing/does not create one, it just returns a warning/message informing the existence, it is not a collapse/disaster.

It is an action with no effective impact for the loop/bat running, requiring only a command with due predictive treatment of possible non-execution where it is not necessary [ run (if folder exists warning) omit ] and continue..., which is perfectly fine resulting from omitting error/warning with 2>nul mkdir Folder_If_Or_Not_Exist & continue