Solved

Time Control:  How to pause for 30 Seconds intervals between each command in DOS-Batch?

Posted on 2003-10-29
12
2,654 Views
Last Modified: 2009-12-16
Hello!   Everyone!

I am listening to many sound clips for my business, and wanted to handle them by my own scripts.   I learned that Windows Media Player can take a command line, so that I wrote my DOS-batch program as below.   It works partially.   Out of 6 clips, the first 5 clips were played for only 1 second and went to the next entry.   Only the last clip was played in full about 30 seconds.   Now I want to insert 30 seconds pause between each command execution.   Any idea or help?   Thank you!!!

Mitsuru Kido

=================================
@echo

REM DOS Batch Program for Media Player
::  DOS Batch Prgoram

mplayer2 e:\contemporary a\abba\00936301 - Dancing Queen.mp2
mplayer2 e:\contemporary a\abba\00936303 - S.O.S..mp2
mplayer2 e:\contemporary a\abba\04810603 - Mamma Mia.mp2
mplayer2 e:\contemporary a\abba\07796302 - Take A Chance On Me.mp2
mplayer2 e:\contemporary a\abba\07796304 - Chiquitita.mp2
mplayer2 e:\contemporary a\abba\07796305 - Fernando.mp2

0
Comment
Question by:mkido
12 Comments
 
LVL 16

Accepted Solution

by:
_nn_ earned 125 total points
ID: 9642576
A bit stupid, but it works :

@echo off

REM DOS Batch Program for Media Player
::  DOS Batch Prgoram

mplayer2 e:\contemporary a\abba\00936301 - Dancing Queen.mp2
ping -n 31 127.0.0.1 >NUL
mplayer2 e:\contemporary a\abba\00936303 - S.O.S..mp2
ping -n 31 127.0.0.1 >NUL
mplayer2 e:\contemporary a\abba\04810603 - Mamma Mia.mp2
ping -n 31 127.0.0.1 >NUL
mplayer2 e:\contemporary a\abba\07796302 - Take A Chance On Me.mp2
ping -n 31 127.0.0.1 >NUL
mplayer2 e:\contemporary a\abba\07796304 - Chiquitita.mp2
ping -n 31 127.0.0.1 >NUL
mplayer2 e:\contemporary a\abba\07796305 - Fernando.mp2
0
 
LVL 8

Expert Comment

by:K_2K
ID: 9643095
if it's stupid,
        and it works,
              it ain't stupid.
My 2¢,
2K
(\o/)


0
 
LVL 8

Expert Comment

by:K_2K
ID: 9643124
This works for me, but I don't get as much peace between the noise, and those that are over 30 seconds don't stop short like you ask.

*<;-))

=================================
@echo

REM DOS Batch Program for Media Player
::  DOS Batch Prgoram

for %%K in ("e:\contemporary a\abba\*.mp2") do (
    start /wait "2K " mplayer2 e:\contemporary a\abba\00936301 - Dancing Queen.mp2
)
0
Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
LVL 8

Expert Comment

by:K_2K
ID: 9643131
(Not to mention, the unpleasant side-effect of also playing the other tracks in that folder.)
0
 
LVL 8

Expert Comment

by:K_2K
ID: 9643230
Color me stupid - I changed the folder in my test batch and messed up copying back to the post.


for %%K in ("e:\contemporary a\abba\*.mp2") do (
    start /wait "2K " mplayer2 %%K
)
0
 
LVL 16

Expert Comment

by:_nn_
ID: 9643524
Hi K_2K,

Nice loop, but on my W2K box, I have to close the player between each clip. So I've had some fun coding that one :

playlist.bat
----8<-----------------------------
@echo off

if "%1"=="" goto usage

>playlist.asx echo ^<ASX version="3"^>
>>playlist.asx echo.


for %%K in (%1) do (

>>playlist.asx echo ^<ENTRY^>
>>playlist.asx echo   ^<TITLE^>%%K^</TITLE^>
>>playlist.asx echo   ^<REF href="%%K"/^>
>>playlist.asx echo ^</ENTRY^>
>>playlist.asx echo.

)

>>playlist.asx echo.
>>playlist.asx echo ^</ASX^>

start /wait mplayer2 playlist.asx
del playlist.asx


goto end
:usage
echo Usage: %0 <path_and_filemask>

:end
----8<-----------------------------

Cheers :o)
0
 
LVL 8

Expert Comment

by:K_2K
ID: 9643909
sweet,  
gave me a much needed smile on a hard day.

thanks,
2K
(\o/)
0
 
LVL 3

Expert Comment

by:cwp
ID: 9644182
Well, the mplayer2 supports some options as well, try it with /Play and /Close.
0
 
LVL 8

Expert Comment

by:K_2K
ID: 9644451
Options are a good thought, yet I think with MS's track record on memory leaks I'd be happier if I could keep the thing open and let it go to each song itself when done.  Even though I know the old V6 standard player2 is more stable than V7, it still takes less time to switch songs if we don't reinitialize the whole player between tracks.

VB's sendkeys may allow adding songs dynamically to the current play queue.  I still gotta think building the playlist first is a good option and a nice de-paradigm-er if the front-end can use it.
0
 
LVL 9

Expert Comment

by:DrWarezz
ID: 9645772
hey,
I have to go offline soon, so I don't have time to read any of the above so far, therefore, my contribution to this may not be relivant. Either ways, here's a little bit of code tht i put together not too long a go. If you place it into, e.g: your %systemroot%, you can call it whenever u need to.

::---30secondpause.bat---::

@echo off

set TIMM=%TIME::=%
set TIMMM=%TIMM:~0,6%
set /a TIMEN=%TIMMM%+000030

:_STSY
set TIMM=%TIME::=%
set TIMMM=%TIMM:~0,6%
if "%TIMMM%"=="%TIMEN%" exit /b
goto _STSY

::---end---::


By calling this from your batch program, this should cause a pause for 30 seconds.

gd luck

>>Rob:D<<
0
 
LVL 7

Expert Comment

by:YarnoSG
ID: 9651764
There is a resource kit tool called SLEEP that does this

"SLEEP 30"
suspends a batch file for 30 seconds.
0
 

Author Comment

by:mkido
ID: 9654234
Thank you all!
I get to try some out.   Let me see.   Talk to you a little later.  
Mitsuru
0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Excel: Move files in a folder 8 75
robocopy 6 64
network copying issue 4 66
Date variable in batch file 2 29
Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
One of my most closely kept secrets is revealed in this discussion How to output text on the same line This question was recently posted in EE by Simon336697 (http://www.experts-exchange.com/Programming/Languages/Scripting/Shell/Batch/Q_2459…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question