set /a n=1
for %%i in (*.mkv) do (
for %%j in ("A:\Downloads\AoD\AoD (%n%)\*.*") do (
mkvpropedit "%%i" --add-attachment "%%j"
)
set /a n+=1
)
I want to write a script which attaches the conent of the n-th folder in "A:\Downloads\AoD\AoD (%n%)\*.*"
to the n-th .mkv
. The above script didn't work because apparently the entire FOR loop is evaluated before execution. After stumbling across this question, I rewrote my script like this
setlocal enabledelayedexpansion
set /a n=1
for %%i in (*.mkv) do (
for %%j in ("A:\Downloads\AoD\AoD (!n!)\*.*") do (
mkvpropedit "%%i" --add-attachment "%%j"
)
set /a n+=1
)
endlocal
but it somehow still doesn't work. n
increases but apparently !n!
isn't interpreted as a variable but rather as the string !n!
because this is what cmd tells me
B:\AoD try>(
for %j in ("A:\Downloads\AoD\AoD (!n!)\*.*") do (mkvpropedit "AoD (1).mkv" --add-attachment "%j" )
set /a n+=1
)
2
B:\AoD try>(
for %j in ("A:\Downloads\AoD\AoD (!n!)\*.*") do (mkvpropedit "AoD (2).mkv" --add-attachment "%j" )
set /a n+=1
)
3
B:\AoD try>endlocal
This output is from me using the script by pasting it directly into the Command Prompt with only single %
s.