Reputation: 177
I'm using the command line interface version of MediaInfo to extract several parameters (to keep the code brief I only show format and duration below) from several hundred small video tutorials to process them for other uses.
I use a .bat file that gathers the parameters, pipes them to a txt file and then opens the file in Notepad:
f:\path\mediainfo.exe "--Inform=Video;%%Format%%\r\n%%Duration/String%%" "tutorial.mp4" > out.txt
sleep 1
start out.txt
As it stands now I have to cut and paste the actual video name into the batch file (file name is "tutorial.mp4" in code above) because I don't know how to programmatically get that parameter into the mediainfo command.
So, my question is, since the video files will always be either .avi or .mp4, is there a way to add some code to the bat file to look for a file in the directory the bat file is in and if it's either of those two types insert the file name into the first line as I have it now? There will only ever be one single video file in the sub directory and it will be either a .avi or a .mp4. It's remotely possible that there might be other file types in the subdirectory so for this reason I can't say "pick the ONLY file in the subdirectory and insert it into the bat file".
I'm wondering if something along this line added to the top of the file:
IF EXIST *.avi || *.mp4
But I don't know if I can use the OR command like that and I don't know how to assign the filename to a variable and how to use that variable in the mediainfo.exe line.....
Upvotes: 0
Views: 2820
Reputation:
for %%A in ("C:\folder\*.mp4" "C:\folder\*.avi") Do Echo %%A
To see it work listing ini files in Windows (NB interactively you use %A
not %%A
in batch). Paste the below.
for %A in (%windir%\*.ini) do Echo %~tA %~aA %A
See for /?
.
NB this line does nothing sleep 1
. Use Waitfor
, timeout
, or choice
. See each one's help - waitfor /?
, etc.
Upvotes: 2