This sounds dumb, but I can't get it to work. I think i just dont' understand the difference between %%v, %v% and %v
Here's what I'm trying to do:
for %%v in (*.flv) do ffmpeg.exe -i "%%v" -y -f mjpeg -ss 0.001 -vframes 1 -an "%%v.jpg"
This successfully generates a thumbnail for each of the movies, but the problem is:
movie.flv -> movie.flv.jpg
So what I would like to do is pull the last 4 characters off %%v
and use that for the second variable.
I've been trying things like this:
%%v:~0,-3%
But it's not working, nor are any of the iterations of that that I could think of.
Any ideas?
For people who found this thread looking for how to actually perform string operations on for-loop variables (uses delayed expansion):
Use %%~nV to get the filename only.
Yet another way that I prefer is to create a sub-routine (:processMpeg) that I call for each element in the For loop, to which I pass the %%v variable.
From "help for":
I am not as good at batch as the above (I use WSH or other script languages instead) but I can try and explain %%v %v and %v%.
The first two forms are used in a
for
loop.help for
explains the difference, the first form is used in a batch file while the second one is used when typing (pasting) the command directly at the command prompt.The last form just replaces the variable name (environment variable) with its value: