HydrogenAudio

Hosted Forums => foobar2000 => General - (fb2k) => Topic started by: jazzfido on 2012-04-26 09:54:35

Title: One way to use multiple libraries with Foobar2000 (example with three
Post by: jazzfido on 2012-04-26 09:54:35
One way to use multiple libraries with Foobar2000 (example with three libraries).

Foobar2000 doesn't support multiple libraries natively. However, many users may have separate music collections that they want to access independently. This hack provides a relatively easy and unintrusive way of adding a multiple library functionality.

One way of using multiple libraries is to have mulitiple (portable) installations of Foobar2000. The advantage of the method below is that settings, components, layout etc. are maintained in all libraries, which they aren't in the multiple installation approach.

Requirements:

The installation of the software AutoHotKey.

A working Foobar2000 installation (the procedure described below works with version 1.1.11. It should work with previous versions aswell).

Windows XP (the procedure described below works with other versions of Windows, but the file paths will be different).

The Foobar2000 settings are located in the Application Data folder.

Procedure:

1   Install AutoHotKey, which can be downloaded from here: http://www.autohotkey.com/ (http://www.autohotkey.com/)

2   Backup the two files that are being used in this procedure. Open your file manager of choice, e.g. Windows Explorer, and go to

C:\Documents and Settings\YOURNAME\Application Data\foobar2000\ and create a folder called “backup”.

and go to

C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\ and copy the file “Core.cfg” to C:\Documents and Settings\YOURNAME\Application Data\foobar2000\backup\.

and go to

C:\Documents and Settings\YOURNAME\Application Data\foobar2000\ and copy the file “database.dat” to C:\Documents and Settings\YOURNAME\Application Data\foobar2000\backup\.

3   The creation of multiple libraries involves only the two files mentioned above: Core.cfg and database.dat. Now that you have a backup of these, it is time to create two more databases. The three databases will, in the following, be referred to with the names “small”, “medium” and “big”. In my setup, the big database contains the music that is on my server, the medium database contains the music that is on my computer, and the small database contains the music on my computer that has just arrived and is awaiting editing, tagging etc.
   
In C:\Documents and Settings\YOURNAME\Application Data\foobar2000\backup\, rename Core.cfg to Coremedium.cfg and database.dat to databasemedium.dat and copy these files to their respective original directories as mentioned above under point 2.

In C:\Documents and Settings\YOURNAME\Application Data\foobar2000\backup\, Rename Coremedium.cfg to Corebig.cfg and databasemedium.dat to databasebig.dat and copy these files to their respective original directories as mentioned above under point 2.
 
In C:\Documents and Settings\YOURNAME\Application Data\foobar2000\backup\, Rename Corebig.cfg to Core.cfg and databasebig.dat to database.dat.

In the configuration directory mentioned under 2, you should now have three core files with the names Core.cfg, Coremedium.cfg and Corebig.cfg.

In the database directory mentioned under 2, you should now have three database files with the names database.dat, databasemedium.dat and databasebig.dat.

This means that we now have three databases, albeit with the same content, in place.

4   The next step involves the creation of a script to be executed by AutoHotKey.

Open Notepad or your preferred text editor. Copy the following lines into a new document (change YOURNAME to whatever is the correct path in your computer).

Code: [Select]
; THIS ACTIVATES THE DATABASE NAMED SMALL

FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Core.cfg, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Coremedium.cfg
FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Core.cfg, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Corebig.cfg
FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Coresmall.cfg, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Core.cfg

FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\database.dat, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\databasemedium.dat
FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\database.dat, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\databasebig.dat
FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\databasesmall.dat, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\database.dat
Run C:\Program Files\foobar2000\foobar2000.exe

Save the document to C:\Documents and Settings\YOURNAME\Application Data\foobar2000\backup\ with any name, e.g. “foobar2000-smallDB”, but with the extension .ahk (the AutoHotKey extension) instead of .txt.

Open Notepad or your preferred text editor. Copy the following lines into a new document (change YOURNAME to whatever is the correct path in your computer).

Code: [Select]
; THIS ACTIVATES THE DATABASE NAMED MEDIUM

FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Core.cfg, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Coresmall.cfg
FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Core.cfg, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Corebig.cfg
FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Coremedium.cfg, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Core.cfg

FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\database.dat, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\databasesmall.dat
FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\database.dat, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\databasebig.dat
FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\databasemedium.dat, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\database.dat
Run C:\Program Files\foobar2000\foobar2000.exe

Save the document to C:\Documents and Settings\YOURNAME\Application Data\foobar2000\backup\ with any name, e.g. “foobar2000-mediumDB”, but with the extension .ahk (the AutoHotKey extension) instead of .txt.

Open Notepad or your preferred text editor. Copy the following lines into a new document (change YOURNAME to whatever is the correct path in your computer).

Code: [Select]
; THIS ACTIVATES THE DATABASE NAMED BIG

FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Core.cfg, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Coresmall.cfg
FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Core.cfg, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Coremedium.cfg
FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Corebig.cfg, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\configuration\Core.cfg

FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\database.dat, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\databasesmall.dat
FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\database.dat, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\databasemedium.dat
FileMove, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\databasebig.dat, C:\Documents and Settings\YOURNAME\Application Data\foobar2000\database.dat
Run C:\Program Files\foobar2000\foobar2000.exe

Save the document to C:\Documents and Settings\YOURNAME\Application Data\foobar2000\backup\ with any name, e.g. “foobar2000-bigDB”, but with the extension .ahk (the AutoHotKey extension) instead of .txt.

5   These three files will, when executed, open the three different database files. The FileMove function in the script basically renames the Core.cfg and database.dat files according to which database you want to open. Open Foobar2000 by executing an ahk.fil, go to menu/file/preferences/Media Library and enter the correct path for the specific library.

6   To make this slightly neater, it is possible to compile the scripts into .exe files which, among other things, has the advantage that a foobar2000 icon can be used and that you are not dependent on AutoHotKey remaining installed on the computer. To do this you need to access the AutoHotKey folder from Start/All Programs. Click “convert .ahk to .exe”. In the source field, load one of the .ahk file that were created under point 4. In the destination field, choose the folder C:\Documents and Settings\YOURNAME\Application Data\foobar2000\backup\. In the custom icon field you can, for instance, choose an icon from C:\Program Files\foobar2000\icons. Click “convert”. Repeat for the remaining ahk files created under point five. You may have to rename the resulting files to add the .exe extension to the file name. Make shortcuts for these .exe files, and place them on your desktop or whereever you keep your icons.

7   If you only need two libraries I suggest you follow the procedure above, but only make two shortcuts. This will mean that a future installation of a third library will be very easy because it is already there. Using the standard foobar2000 shortcut will open the database with the latest used library.
Title: One way to use multiple libraries with Foobar2000 (example with three
Post by: MrEnergizer on 2012-04-26 11:55:49
Wow hope this works....been after something like this for years. Thanks
Title: One way to use multiple libraries with Foobar2000 (example with three
Post by: Kohlrabi on 2012-04-26 17:16:05
Album List Viewer (http://wiki.hydrogenaudio.org/index.php?title=Foobar2000%3a%50references:Album_List) or Facets (http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Components/Facets_(foo_facets)) and $directory(x) (http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Titleformat_Reference#.24directory.28x.29).

Nice effort, though.
Title: One way to use multiple libraries with Foobar2000 (example with three
Post by: MrEnergizer on 2012-05-01 12:10:29
Album List Viewer (http://wiki.hydrogenaudio.org/index.php?title=Foobar2000%3a%50references:Album_List) or Facets (http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Components/Facets_(foo_facets)) and $directory(x) (http://wiki.hydrogenaudio.org/index.php?title=Foobar2000:Titleformat_Reference#.24directory.28x.29).

Nice effort, though.


AFAIK ....those methods are just ways of viewing different libraries and are not suitable for handling different folders that may contain copies of tracks in different formats as has been much discussed on this forum.  Hopefully the way above is a solution to manage multiple libraries.
I havent had chance to check it out yet but will give it a go.
Title: One way to use multiple libraries with Foobar2000 (example with three
Post by: Andreasvb on 2012-05-01 13:08:07
You can replace C:\Documents and Settings\YOURNAME\Application Data\foobar2000 with %appdata%\foobar2000
Title: One way to use multiple libraries with Foobar2000 (example with three
Post by: Kohlrabi on 2012-05-01 18:41:48
those methods are just ways of viewing different libraries and are not suitable for handling different folders that may contain copies of tracks in different formats as has been much discussed on this forum.

Handling multiple versions mainly necessitates proper metadata and use of title formatting than the use of multiple libraries, imho.
Title: One way to use multiple libraries with Foobar2000 (example with three
Post by: MrEnergizer on 2012-05-02 14:27:49
You can replace C:\Documents and Settings\YOURNAME\Application Data\foobar2000 with %appdata%\foobar2000

Thanks
Title: One way to use multiple libraries with Foobar2000 (example with three
Post by: MrEnergizer on 2012-05-02 14:40:06
those methods are just ways of viewing different libraries and are not suitable for handling different folders that may contain copies of tracks in different formats as has been much discussed on this forum.

Handling multiple versions mainly necessitates proper metadata and use of title formatting than the use of multiple libraries, imho.


I use Album List Panel Kohlrabi....But I obviously haven't got the coding skills to accomplish this. I am able to split the folders up in views but have always found that the media is still 'physically' there so once you select a whole tree all the files appear (regardless of codec) hence creating doubles.
Sorry but I haven't got the technical knowledge or jargon to explain myself properly.
Title: One way to use multiple libraries with Foobar2000 (example with three
Post by: jazzfido on 2012-05-03 09:41:58
Inspired by Andreasvb's code revelation above (thank you!) I decided to automate the procedure a bit, i.e. making the creation of three databases a lot easier.

So, an alternative way to install multiple libraries is to do the following.

1. Download multipleDBexe.zip from http://www.mediafire.com/?9pv0apdou1l5cp6 (http://www.mediafire.com/?9pv0apdou1l5cp6)

2. Unzip the files - create-databases-in-foobar.exe, foobar2000-smallDB.exe, foobar2000-mediumDB.exe and foobar2000-bigDB.exe - to your desktop (not in a folder)

3. Make sure foobar2000 is closed

4. Execute create-databases-in-foobar.exe

create-databases-in-foobar.exe does the following:

a. Moves the unzipped files foobar2000-smallDB.exe, foobar2000-mediumDB.exe and foobar2000-bigDB.exe from the desktop to %appdata%\foobar2000\ (these three .exe files are used to open foobar2000 with three different databases).

b. Creates a backup directory, %appdata%\foobar2000\backup\, and copies Core.Cfg and database.dat to this directory (just in case).

c. Creates an additional two databases in %appdata%\foobar2000\ with the names databasesmall.dat and databasemedium.dat. The existing database, database.dat, is, in effect, databasebig.dat. The two new databases are copies of database.dat.

d. Creates shortcuts for the three databases and places these shortcuts on the desktop.

5. Delete create-databases-in-foobar.exe

6. Open foobar2000 by using the foobar2000-smallDB shortcut on the desktop and go to menu/library/media library and add the correct folders for this database (and remove any that are not required). Close foobar2000.

7. Open foobar2000 by using the foobar2000-mediumDB shortcut on the desktop (if you need 3 databases) and go to menu/library/media library and add the correct folders for this database (and remove any that are not required). Close foobar2000.

Use the three shortcuts that have been created on the desktop to open foobar2000 with different database content.

If you need the AutoHotKey files, they can be downloaded from here: http://www.mediafire.com/?p8tqoqik3j87j6i (http://www.mediafire.com/?p8tqoqik3j87j6i)
Title: One way to use multiple libraries with Foobar2000 (example with three
Post by: Kohlrabi on 2012-05-03 12:46:35
Sorry but I haven't got the technical knowledge or jargon to explain myself properly.

Nothing to be sorry about, I don't have any gripes with this solution, I just wanted to mention that similar functionality can be achieved within foobar2000 itself.
Title: One way to use multiple libraries with Foobar2000 (example with three
Post by: MrEnergizer on 2012-05-03 15:10:36
Thanks Jazzfido