Multiple Libraries - Portable MM - Batch file

Get answers about using MediaMonkey 4 for Windows.

Moderator: Gurus

KyleHx
Posts: 49
Joined: Fri Mar 13, 2015 11:09 am

Multiple Libraries - Portable MM - Batch file

Post by KyleHx »

There has been much talk of separate libraries, rather than Collections, in MediaMonkey.
MediaMonkey does do Collections -- it doesn't do Libraries.

I am not going to re-visit the discussions of pros & cons, here. This isn't about that.
This is just a way to set up and work with separate libraries, if you're interested.

This ONLY works with a PORTABLE installation of MediaMonkey.

This is all centered on a batch file, MM.BAT, which is at the end of this post.
The batch file uses my own directories & structures, so it might take some work to use it.

Working with files to edit tags is a much different environment from playing music.
There are many different parameters that apply in different ways to different groupings of files, and I have different ways I want to see and work with subsets of my entire collection.

So, I am trying out this approach.
For organizing & editing, I use separate libraries.
For presenting & playing, I use the single, combined, master library.

As the previous posts have noted, switching libraries means exiting & re-starting MediaMonkey.

This DOES, unavoidably, require lots of rescans.
So the next job on my list is to automate & optimize such rescans (for all libraries).

(I use an old program from an ancient copy of Norton Utilities, called BE.EXE -- to ask a question in a batch file & present a list of possible answers. There are undoubtedly alternatives out there. Also, you can write a front-end batch file for my MM.BAT to skip the prompts.)

**********************************
My sound files are stored like this:
\{dir-tree}\!Music
...\!new
...\Artists
...\Bundles
...\Classical
\{dir-tree}\!Sounds
...\Ring-Tones
...\other

The MediaMonkey (portable) program directory has this structure:
\{dir-tree}\MediaMonkey
...\Brand
...\Equalizer
...\Libraries <<*** My added dir
...\License
...\Locale
...\Plugins
...\Portable
...\Scripts
...\Skins

The Libraries tree has:
.\MediaMonkey\Libraries
...\!new
...\Artists
...\Bundles
...\Classical
...\Music
...\Sounds
...\Totality
...\virgin
These are for storing MM.DB & MediaMonkey.INI & MediaMonkey.REGISTRY files.
The ".\Music" and ".\Totality" nodes are "virtual" libraries.
The "Music" library is a MM.DB (rescan) of Artists+Bundles+Classical.
"Sounds" is different (like for ring-tones), so there's a separate library.
And so there's also a separate "Totality" library that has all of the above.
The "virgin" directory is storage for base-line copies of MM.DB & .INI & .REGISTRY.
**********************************

MM.BAT is a bit complicated, and it has many pointers to my own directories.
So, it will undoubtedly require some editing to match your structure.
Once that's done, you can create a simple front-end for MM.BAT, which will bypass the prompts (and the need for BE.EXE), and start MediaMonkey with a particular library.

mmA.bat == A sample front-end for MM.bat:

set MMDrv=C:
set MMDir=\!apps\MediaMonkey
set MMLib=Artists
MM

mmC.bat == A sample front-end for MM.bat:

set MMDrv=C:
set MMDir=\!apps\MediaMonkey
set MMLib=Classical
MM /Party

mmX.bat == A sample front-end for MM.bat (uses MM defaults):

MM 9 /Play

**********************************

MM.BAT

Code: Select all

@echo off

rem MediaMonkey.exe command-line options
rem /INIFILE *BUG* causes Windows registry to be used (not MediaMonkey.Registry file)
rem /NoSplash makes start-up much faster
rem /Minimized
rem /Next - play files after the current track
rem /Add - add files to the Now Playing queue
rem /Party - start up in Party Mode
rem /Play - start up and play whatever is currently in the Now Playing queue
rem /ResetToolbars - resets toolbar configuration to default settings

rem Primary Defaults
if *%MMDrv%*==** set MMDrv=C:
if *%MMDir%*==** set MMDir=\!apps\MediaMonkey

rem if have an invalid drive, bat attempts a fall-back, in order shown
if not exist "%MMDrv%%MMDir%\MediaMonkey*.*" set MMDrv=C:
if not exist "%MMDrv%%MMDir%\MediaMonkey*.*" set MMDrv=T:
if not exist "%MMDrv%%MMDir%\MediaMonkey*.*" set MMDrv=V:
if not exist "%MMDrv%%MMDir%\MediaMonkey*.*" set MMDrv=G:
if not exist "%MMDrv%%MMDir%\MediaMonkey*.*" set MMDrv=M:
if not exist "%MMDrv%%MMDir%\MediaMonkey*.*" goto ERROR-1

if *%1*==** goto MMASK

:FrontEnd-A = use manual settings (must have set MMDrv + MMDir + MMLib)
if not *%MMLib%*==** goto RUN!
:FrontEnd-B = use MMASK options
set MMANS=
for %%V in (1 2 3 5 6 8 9) do if *%1*==*%%V* set MMANS=%%V
if *%MMANS*==** goto MMASK
shift
goto RUN-%MMANS%

:MMASK
if *%MMDrv%*==** goto ERROR-2
if *%MMDir%*==** goto ERROR-2
if not exist "%MMDrv%%MMDir%\MediaMonkey*.*" goto ERROR-1
cls
echo MediaMonkey (portable installation)
echo ~~~~~~~~~~~
echo Base Libraries (main directories):
echo.
echo     1) Artists      ³   5) Sounds
echo     2) Bundles      ³   6) new stuff
echo     3) Classical 
echo.
echo Combo Libraries (not music-file dirs):
echo.
echo    (8) Music .. Artists + Bundles + Classical
echo    (9) Totality .. Everything (Music + Sounds + New)
echo.
echo Now using: Drive %MMDrv%
echo     C) set Drive C: == main
echo     T) set Drive T: == Things on Sys_#1
echo     V) set Drive V: == Things on Sys_#2
echo     G) set Drive G: == Things on Sys_#3
echo.
echo If the system crashed before finishing the last run of MM.BAT,
echo (before copying key files), you can use (R) to try to fix that.
echo.
echo Use Q) to Quit
echo.
BE Ask "Eh? ",123456789QRCTVGM
if errorlevel 16 goto Run-M
if errorlevel 15 goto Run-G
if errorlevel 14 goto Run-V
if errorlevel 13 goto Run-T
if errorlevel 12 goto Run-C
if errorlevel 11 goto RESTORE
if errorlevel 10 goto END
if errorlevel 9 goto Run-9
if errorlevel 8 goto Run-8
if errorlevel 7 goto Run-7
if errorlevel 6 goto Run-6
if errorlevel 5 goto Run-5
if errorlevel 4 goto Run-4
if errorlevel 3 goto Run-3
if errorlevel 2 goto Run-2
if errorlevel 1 goto Run-1
goto END

:Run-C
set MMDrv=C:
if not exist "%MMDrv%%MMDir%\MediaMonkey*.*" goto ERROR-1
goto MMASK

:Run-T
set MMDrv=T:
if not exist "%MMDrv%%MMDir%\MediaMonkey*.*" goto ERROR-1
goto MMASK

:Run-V
set MMDrv=V:
if not exist "%MMDrv%%MMDir%\MediaMonkey*.*" goto ERROR-1
goto MMASK

:Run-G
set MMDrv=G:
if not exist "%MMDrv%%MMDir%\MediaMonkey*.*" goto ERROR-1
goto MMASK

:Run-M
set MMDrv=M:
if not exist "%MMDrv%%MMDir%\MediaMonkey*.*" goto ERROR-1
goto MMASK

:Run-1
echo *1 = Artists
set MMLib=Artists
goto RUN!

:Run-2
echo *2 = Bundles
set MMLib=Bundles
goto RUN!

:Run-3
echo *3 = Classical
set MMLib=Classical
goto RUN!

:Run-4
echo *4 NOT SET UP YET
pause
goto MMASK

:Run-5
echo *5 = Sounds
set MMLib=Sounds
goto RUN!

:Run-6
echo *6 = !new
set MMLib=!new
goto RUN!

:Run-7
echo *7 NOT SET UP YET
pause
goto MMASK

:Run-8
echo *8 = Music
set MMLib=Music
goto RUN!

:Run-9
echo *9 = Totality
set MMLib=Totality
goto RUN!

:RUN!
:run!chk
%MMDrv%
cd "%MMDir%
if not exist "Portable\*.*" goto ERROR-1
if not exist "Libraries\*.*" goto ERROR-1
cd Libraries
if not exist "%MMLib%\mm.db" goto ERROR-1
if not exist "%MMLib%\MediaMonkey.ini" goto ERROR-1
if not exist "%MMLib%\MediaMonkey.Registry" goto ERROR-1
:run!set
copy "%MMLib%\MediaMonkey.ini" ..\Portable
copy "%MMLib%\MediaMonkey.Registry" ..\Portable
:run!run
cd..
echo MMDrv: %MMDrv%
echo MMDir: %MMDir%
echo MMLib: %MMLib%
MediaMonkey.exe /NoSplash %1 %2 %3 %4 %5 %6 %7 %8 %9
:run!end
%MMDrv%
cd "%MMDir%\Libraries\%MMLIB%
copy "..\..\Portable\MediaMonkey.Registry"
copy "..\..\Portable\MediaMonkey.ini"
goto END

:ERROR-1
echo.
echo Files Missing
echo.
echo MMDrv = %MMDrv%
echo MMDir = %MMDir%
echo MMLib = %MMLib%
goto ENDERR

:ERROR-2
echo.
echo Error with Environment variables

:ENDERR
echo.
pause
goto END

:RESTORE
set MMTmp=
set MMVer=
cls
echo This sub-routine is only for recovering after a crash which didn't allow
echo MM.BAT to finish (ie, before copying the active .\Portable files back to
echo the appropriate .\Library directory).  Check the following listings.
echo.
echo --Looking for the key files:
echo --MediaMonkey.ini + MediaMonkey.Registry
dir ..\Portable\MediaMonkey.* |find /i /v ".m3u8" |find /i /v "File(s)" |find /i /v "Dir(s)" |find /i /v "Volume in" |find /i /v "Serial "
echo.
echo --Looking for DBNAME= line in the copy of MediaMonkey.ini under .\Portable
echo --This is the pointer to the library's MM.DB -- presented for verifcation.
echo.
type ..\Portable\MediaMonkey.ini |find /i "DBNAME="
echo.
echo ---------------------------------------------------------------------
echo Check the above before continuing.
pause
echo.
echo To force a copy of these .\Portable files to the the .\Library directory,
echo   select an option below.  (I'll try to save a "Pre-Restore" copy.)
echo (This only applies to the .INI and .Registry -- MM.DB isn't affected.)
echo.
echo Copy .\Portable files to one of these library-directories:
echo.
echo     1) Artists      ³   5) Sounds       ³   (8) Music
echo     2) Bundles      ³   6) new stuff    ³   (9) Totality
echo     3) Classical    ³                   ³
echo.
echo Or, use (Q) to Quit this sub-routine.
echo.
BE Ask "Huh? ",1235689Q
if errorlevel 1 set MMTmp=Artists
if errorlevel 2 set MMTmp=Bundles
if errorlevel 3 set MMTmp=Classical
if errorlevel 4 set MMTmp=Sounds
if errorlevel 5 set MMTmp=!new
if errorlevel 6 set MMTmp=Music
if errorlevel 7 set MMTmp=Totality
if errorlevel 8 goto RESTOREND
if not exist "%MMTmp%\MediaMonkey.Pre-Restore.9" set MMVer=9
if not exist "%MMTmp%\MediaMonkey.Pre-Restore.8" set MMVer=8
if not exist "%MMTmp%\MediaMonkey.Pre-Restore.7" set MMVer=7
if not exist "%MMTmp%\MediaMonkey.Pre-Restore.6" set MMVer=6
if not exist "%MMTmp%\MediaMonkey.Pre-Restore.5" set MMVer=5
if not exist "%MMTmp%\MediaMonkey.Pre-Restore.4" set MMVer=4
if not exist "%MMTmp%\MediaMonkey.Pre-Restore.3" set MMVer=3
if not exist "%MMTmp%\MediaMonkey.Pre-Restore.2" set MMVer=2
if not exist "%MMTmp%\MediaMonkey.Pre-Restore.1" set MMVer=1
ren "%MMTmp%\MediaMonkey.ini" "MediaMonkey.ini.Pre-Restore.%MMVer%"
ren "%MMTmp%\MediaMonkey.Registry" "MediaMonkey.Registry.Pre-Restore.%MMVer%"
copy "..\Portable\MediaMonkey.ini" "%MMTmp%"
copy "..\Portable\MediaMonkey.Registry" "%MMTmp%"
:RESTOREND
echo.
pause
goto MMASK

:END
EXIT
To implement it, create a "Libraries" directory on the same level as "Portable"
Under Libraries, create a separate directory for each one you want.

Copy 3 files from the original Portable directory to each of your Library directories.
.. MM.DB + MediaMonkey.ini + MediaMonkey.Registry
(optional: rename the originals, under Portable, for backup & verifcation.)
(optional: delete one of the MM.DBs and re-scan from scratch for that Library.)

Edit each of the MediaMonkey.ini files ..
under [System] add a DBNAME= pointer, such as in:
[System]
SQLiteSafety=0
DBName=Libraries\Artists\mm.db
JustInstalled=0

Put MM.BAT in the Library directory (along with BE.EXE or equivalent, if desired).
Run MM.BAT from .\MediaMonkey\Libraries.

**********************************
One last note:
If you run MediaMonkey.exe from the main program directory, it will use the last copied .INI and .REGISTRY files (and the MM.DB thereby pointed to). On exit, it will NOT copy those files back to the Library directories, so when next running MM.BAT, any changes to the .INI and .REGISTRY will be lost (but MM.DB changes will be saved).
If you do want to run MediaMonkey.exe itself, copy the files appropriately afterwards.
**********************************
Another last note:
MediaMonkey portable had a problem with /INIFILE and thereafter used my Windows Registry instead of
the MediaMonkey.Registry file. If you have a hiccup in MediaMonkey, and notice that settings that
should be different between Libraries end up being the same, it could be a similar situation.
It seems that once MediaMonkey-Portable does start using the Windows Registry, it won't stop.

To fix this, exit MediaMonkey - run RegEdit - delete the RegKey shown below - Restart MediaMonkey
HKEY_CURRENT_USER\Software\MediaMonkey

The "portable" installation shouldn't write to the registry at all, but it does.
The difference is that in a "clean" setup, the RegKey will only be partially populated.
You'll quickly see the difference .. there is a whole lot less under that key when the
MediaMonkey.Registry file is being used properly. Plus, your Libraries can now differ.
**********************************
The real last note:
If an add-on creates or edits lines in MediaMonkey.ini or MediaMonkey.Registry, those changes will
only be made in & preserved for the current library. For new add-on installations, you may have to
run the installer (usually a .MMIP file) for each library (I've never had a problem doing that), or
make the edits yourself to all the .INI and/or .Registry files under Libraries.
Last edited by KyleHx on Sat Jun 06, 2015 4:44 pm, edited 31 times in total.
KyleHx
Posts: 49
Joined: Fri Mar 13, 2015 11:09 am

Re: Multiple Libraries - Portable MM - Batch file

Post by KyleHx »

If you're wondering why I didn't use the /INIFILE command-line option, see:

..Bug-Note: Truly portable installation?
....http://www.mediamonkey.com/forum/viewto ... LE#p408651
..And: trouble-ticket
....http://www.ventismedia.com/mantis/view.php?id=12739

I've seen no comparable issues with the DBNAME= option in MediaMonkey.INI

Also note: DBNAME= under [System] in MediaMonkey.ini will accept relative paths.
So, instead of DBNAME=c:\!apps\MediaMonkey\Libraries\Artists\MM.DB
I have: DBName=Libraries\Artists\mm.db
Last edited by KyleHx on Sat Jun 06, 2015 1:18 pm, edited 3 times in total.
nohitter151
Posts: 23640
Joined: Wed Aug 09, 2006 10:20 am
Location: NJ, USA
Contact:

Re: Multiple Libraries - Portable MM - Batch file

Post by nohitter151 »

You should surround your BAT code with code tags:

Code: Select all

[code]
[/code]
MediaMonkey user since 2006
Need help? Got a suggestion? Can't find something?

Please no PMs in reply to a post. Just reply in the thread.
KyleHx
Posts: 49
Joined: Fri Mar 13, 2015 11:09 am

Re: Multiple Libraries - Portable MM - Batch file

Post by KyleHx »

:)
Post Reply