-1

I am using builtin cmd commands & mediainfo utility to get three parameters for media filenames stored in a TXT file but help will be appreciated as I can't make it work

From here I scrapped code for mediainfo: https://stackoverflow.com/a/19091772/1162750

my code is

@echo off
cls
if exist mediafiles.txt del mediafiles.txt
dir /s/b . > mediafiles.txt
for /F "tokens=*" %%i in  (mediafiles.txt) do  (
    set /a dur=mediainfo --Inform="Video;%Duration%" "%%i"
    set /a mins=(%dur%/1000)/60
    set size=%%~zi
    set /a MB=(%size%/1024)/1024
    echo %%i,%mins%,%MB% >> mediafiles.csv
)
@echo on

FileDuration is being converted to minutes from milliseconds (default mediainfo output) & FileSize in MBs

nightcrawler
  • 275
  • 5
  • 16
  • You need to invoke delayedexpansion [hundreds of SO articles about that - use the search feature] in order to display or use the run-time value of any variable that's changed within a parenthesised series of instructions (aka "code block"). – Magoo Jan 20 '18 at 23:47
  • Please take the [tour], read [Ask] and [MCVE]. "I can't make it work" is not a good problem statement and definitely not a question. What exactly isn't working? What does the script do and what did you expect it to do? – jwdonahue Jan 21 '18 at 01:56
  • this line `set /a dur=mediainfo --Inform="Video;%Duration%" "%%i"` throws error `Missing Operator` – nightcrawler Jan 21 '18 at 13:41

1 Answers1

0

set /a dur=mediainfo --Inform="Video;%Duration%" "%%i" doesn't work. To get the output of a command, use a for /f loop:

for "delims=" %%a in ('mediainfo --Inform="Video;%Duration%" "%%i"') do set "dur=%%A"

(assuming, you have a variable %Duration%; If you need %Duration% literal, double the percent signs:

for "delims=" %%a in ('mediainfo --Inform="Video;%%Duration%%" "%%i"') do set "dur=%%A"
Stephan
  • 53,940
  • 10
  • 58
  • 91