There is this command line tool for MediaInfo that we use to print video file information. E.g. I want to get video file duration value:
mediainfo --Inform=General;%Duration/String2% video.mkv
46 min 57 s
As you can see it prints 46 min 57 s
which is correct.
Now lets say I want to put that value into a variable. So we run this:
for /f "usebackq" %a in (`"mediainfo --Inform=General;%%Duration/String2%% video.mkv"`) do set duration=%a
set duration=%46
As you can see it gives set duration=%46
on a new line? And if I type next %duration%
I get:
'%46' is not recognized as an internal or external command,
operable program or batch file.
What is going on? How do I get my %duration%
variable show 46 min 57 s
?
for /f "usebackqDELIMS=" %%a
The default delimiters include space. This syntax disables delimiters so the entire line is assigned.
The metavariable
a needs to have 2 %
if you are running a batch file containintg this line. If you are running from the prompt, you need %a
. This applies to the assignment instruction as well.
No idea what you are attempting to do with the %46
malarkey. Please explain.