How to use output of last command

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
skwirrel
Posts: 2
Joined: 01 Jun 2012 04:48

How to use output of last command

#1 Post by skwirrel » 01 Jun 2012 04:58

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to use output of last command

#2 Post by foxidrive » 01 Jun 2012 05:49

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

Squashman
Expert
Posts: 4473
Joined: 23 Dec 2011 13:59

Re: How to use output of last command

#3 Post by Squashman » 01 Jun 2012 05:50

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

foxidrive
Expert
Posts: 6031
Joined: 10 Feb 2012 02:20

Re: How to use output of last command

#4 Post by foxidrive » 01 Jun 2012 05:54

There's a batch file here that can convert MP4 to MKV using handbrake.

viewtopic.php?p=16563#p16563

skwirrel
Posts: 2
Joined: 01 Jun 2012 04:48

Re: How to use output of last command

#5 Post by skwirrel » 01 Jun 2012 11:40

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 :).

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: How to use output of last command

#6 Post by Fawers » 01 Jun 2012 16:08

skwirrel wrote:it's always cooler when you can run something you made yourself :).

True.

Squashman
Expert
Posts: 4473
Joined: 23 Dec 2011 13:59

Re: How to use output of last command

#7 Post by Squashman » 01 Jun 2012 18:41

Fawers wrote:
skwirrel wrote:it's always cooler when you can run something you made yourself :).

True.

0 :mrgreen:

Fawers
Posts: 187
Joined: 08 Apr 2012 17:11
Contact:

Re: How to use output of last command

#8 Post by Fawers » 01 Jun 2012 23:07

Squashman wrote:
Fawers wrote:True.

0 :mrgreen:

I C what you did there. :P

Post Reply