INTERACT FORUM

Please login or register.

Login with username, password and session length
Advanced search  
Pages: [1]   Go Down

Author Topic: Scronch Batch Files  (Read 760 times)

Scronch

  • Guest
Scronch Batch Files
« on: September 17, 2002, 12:29:19 am »

JimH asked that I post these, so here they are.  Not real tough to set up, but I've found them to be helpful.  Other users would need to edit them for their own purposes.  Also, I'm running Windows 2000 Professional.  Microsoft sometimes changes how batch commands are handled from o/s to o/s (yeah, I know...).

The concept is that batch files are kicked off as scheduled events to start MJ with a desired smartlist based on the time of day, and, at certain times later in the day, to change smoothly to different playlists.  I use Windows Task Scheduler ("Scheduled Tasks" on the Win2k Control Panel), because I had trouble with Media Scheduler replicating batch file tasks.  If that is or will be fixed, I assume either one would work fine.  Although Task Scheduler allows you to choose the .bat file directly as the task.

Note: My smartlists use the Not Last Played: <999999 to avoid repeating any songs until I clear Recently Played.  This has been discussed elsewhere in this forum.

All the batch files are kept in the same directory.

I have 4 smartlists, covering the afternoon (before 4pm), evening (4-7pm), night (7-10pm), and late (after 10pm).  My naming conventions are not important, but you need to be consistent.  Here is how I chose to schedule the tasks with Windows Task Scheduler:

c:\temp\MJbatch\mjbyhour.bat
  at 11:01am, 4:01pm, 7:01pm, 10:01pm on the days I chose.

c:\temp\MJbatch\mjgoodnight.bat
  at the time I chose on the days I chose.

c:\temp\MJbatch\mjclose.bat
  two minutes later than mjgoodnight on the days I chose
  (because the goodnight playlist is about a minute).

OK, so here is the "main" batch file.  This file determines what the hour is, and then calls one of four other batch files (for example, mj-1-aft.bat).  This is done whether or not MJ is already running.



@echo off
for /f "tokens=1-4 delims=:., " %%a in ('echo %time%') do (set hour=%%a)
echo Hour is %hour%

if 3 leq %hour% if %hour% leq 15 mj-1-aft
if 16 leq %hour% if %hour% leq 18 mj-2-eve
if 19 leq %hour% if %hour% leq 21 mj-3-nite
if 22 leq %hour% if %hour% leq 23 mj-4-late
if 0 leq %hour% if %hour% leq 2 mj-4-late

set hour=


Here is mj-1-aft.bat.  The other 3 files are very similar.  Notice that the currently playing song is not stopped (thanks, Nikolay).


@echo off
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Mode Minime
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command VolumeSet 80
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Clear DontRemoveCurrent
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Append "TREEPATH=Playlists\1 - Afternoon (noon-4pm)"


Here is the "goodnight" batch file.  It is called as a scheduled task, not from within the main batch file.  Notice that the volume is increased for the goodnight playlist.  However, the volume cannot be decreased in this batch file, because with the commands being handled asynchronously, the volume would go up and back down before the list ever played.  So instead, the list completes, then MJ sits there idle for about a minute until the "close" batch file closes it up.  Note also the ToggeShuffle and ToggleContinuous commands.  These allow the playlist to load withing being shuffled, and MJ to stop playing at the end of the list.  But these commands can cause trouble, because you don't know for certain the state of Shuffle and Continuous (there may have been a problem).  Toggle On/Off and Shuffle On/Off commands would be much, much better.


@echo off
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Mode Minime
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Clear
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command VolumeSet 100
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command ToggleShuffle
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command ToggleContinuous
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Play "TREEPATH=Playlists\Mixes\Good Night"


And then MJ is closed down 2 minutes after the goodnight batch file runs, by having a scheduled task run this "close" batch file.


@echo off
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Mode Minime
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Clear
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command VolumeSet 80
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command ToggleShuffle
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command ToggleContinuous
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Close


That's it for what I have working.  But there is one other thing I'd like to work.  While MJ is playing, I want to be able to batch control the following: clear what's playing, increase the volume, play one song, decrease the volume, continue with the next song in Playing Now.  This will not work, because the commands are handled asynchronously, and the two volume commands complete before any action is taken.


@echo off
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Mode Megame
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Clear
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command VolumeSet 100
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Play "TREEPATH=Playlists\Mixes\OneSongList"
echo Waiting 2 second(s)...
echo Do                      >%TEMP%.\~tmp.vbs
echo Loop Until True = False>>%TEMP%.\~tmp.vbs
CSCRIPT //B //Nologo //T:2 %TEMP%.\~tmp.vbs
del %TEMP%.\~tmp.vbs
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Command VolumeSet 80
"C:\Program Files\J River\Media Jukebox\mjextman.exe" /Append "TREEPATH=Playlists\4 - Late (10-12pm)"


I have added (and varied) the 2 second delay, but it doesn't matter.  The volume increase doesn't stay.  In fact, the /Append command smashes the /Play command, and the OneSongList is never even heard.

There are good reasons why JRiver wouldn't make these commands wait for one another to complete (for example, you want to allow interactive control of MJ in between automated commands).  But there should be some way to raise the volume of one song (no, I haven't had a chance to Reply Gain everything; I realize that could be the answer).  And even with asynchronous commands, the later /Append shouldn't smash the earlier /Play.

What would be really great would be if everything done above could be set up right within MJ!

Hopefully these files will be helpful to some other users.  And, in return, maybe they will send the Packers some DB's.  :(

Scronch
Logged

Cmagic

  • Regular Member
  • Citizen of the Universe
  • *****
  • Posts: 1196
  • Enjoying life with a little music....
RE:Scronch Batch Files
« Reply #1 on: September 17, 2002, 12:41:35 am »

Thank you Scronch,

Think this will be helpful to the MJers :)
I'm goona try that tonight (for now I have to go back to work !)

Christian
Logged
Until the color of a man's skin is of no more significance
than the color of his eyes.
Bob Marley (War)
Pages: [1]   Go Up