Page 1 of 1

How to use output of last command

Posted: 01 Jun 2012 04:58
by skwirrel
Hello,

I am writing a batch file to automate mp4 to mkv remuxing, but i need to be able to use the output of my last command as a variable, eg:

Code: Select all

C:\Users\Skwirrel\Desktop\ \video>mp4box "files\12 S01E01 Pilot - Schijn Bedriegt.mp4" -info 1
Track # 1 Info - TrackID 1 - TimeScale 25000 - Duration 01:03:38.960
Media Info: Language "Undetermined" - Type "vide" - Sub Type "avc1" - 95474 samples
Handler name: mctemp7772622bfc7153d5.264#video:fps=25:par=1:1 - Imported with GPAC 0.4.6-DEV-rev3923
MPEG-4 Config
        Visual Stream - ObjectTypeIndication 0x21
        AVC/H264 Video - Visual Size 720 x 576 - Profile High @ Level 3
Pixel Aspect Ratio 1:1 - Indicated track size 720 x 576
        Decoding Buffer size 108277 - Average bitrate 967 kbps - Max Bitrate 4620 kbps
        No stream dependencies for decoding
        StreamPriority 0

Computed info from media:
        Total size 473179007 bytes - Total samples duration 3818959 ms
        Average rate 968 kbps - Max Rate 4620 kbps

I only need the first line of the output of this command, actually only the value of the timescale: 25000, but I really don't know how to do this (I only discovered the use of .bat-files yesterday :)).

Thanks to anyone who can help me with this :D,
Skwirrel

Re: How to use output of last command

Posted: 01 Jun 2012 05:49
by foxidrive
This is not the best way to do it for lots of file but it shows one way of getting it.

Code: Select all

@echo off

mp4box "files\12 S01E01 Pilot - Schijn Bedriegt.mp4" -info 1 >file.txt

for /f "tokens=10 delims= " %%a in ('find /i "timescale" ^< "file.txt"') do set timescale=%%a
echo %timescale%

pause

Re: How to use output of last command

Posted: 01 Jun 2012 05:50
by Squashman

Code: Select all

@echo off
FOR /F "Tokens=3 Delims=-" %%G in ('mp4box "files\12 S01E01 Pilot - Schijn Bedriegt.mp4" -info 1 ^|findstr /C:"TimeScale"') DO echo %%G

Re: How to use output of last command

Posted: 01 Jun 2012 05:54
by foxidrive
There's a batch file here that can convert MP4 to MKV using handbrake.

viewtopic.php?p=16563#p16563

Re: How to use output of last command

Posted: 01 Jun 2012 11:40
by skwirrel
Thanks :D. Guess it'll work now :).
I try to make a batch file my own, it's always cooler when you can run something you made yourself :).

Re: How to use output of last command

Posted: 01 Jun 2012 16:08
by Fawers
skwirrel wrote:it's always cooler when you can run something you made yourself :).

True.

Re: How to use output of last command

Posted: 01 Jun 2012 18:41
by Squashman
Fawers wrote:
skwirrel wrote:it's always cooler when you can run something you made yourself :).

True.

0 :mrgreen:

Re: How to use output of last command

Posted: 01 Jun 2012 23:07
by Fawers
Squashman wrote:
Fawers wrote:True.

0 :mrgreen:

I C what you did there. :P