Note that this Wiki is a work in progress, items may not be updated or may disappear entirely as the pages are updated.

How do I update my song database if I move songs from one drive to another

From SpacialAudio

Jump to: navigation, search

If you copy your songs from one drive to another and MAINTAIN EXACT directory structure you can use this PAL script to update your database.
Simply tell it the drive letter you moved from and the drive letter you moved to and off it goes. Pretty cool stuff.
For example:
If you tell the script that you moved files from the D drive to your F drive, all filenames that start with D:\\ will be updated to F:\\
This script will change the filename of EVERY song in the database whose DRIVE LETTER matches what you put in the script.
If you moved songs from C:\\daysongs\\ but did not move songs from C:\\nightsongs DON\"T USE THIS SCRIPT because the values of ALL songs on the C:\\ drive will update.

Cool?

You may download the script here. http://spacialnet.com/knowledge/attachment.php?attId=57 (retrieve below from archive.org)

{******************************************************************************
PAL Script: Filedrive Correction

Ever move your files to new drives? Hate having to go through your database
and correct each file manually? Use this script to automatically update your
database when you move files to a new drive!!!!

THIS SCIPT WILL ONLY WORK IF THE DIRECTORY STRUCTURE IS IDENTICAL ON BOTH DRIVES
For example:

If you moved your file from C:\mp3_collection you must move it to the
'mp3_collection' folder on the root of your new drive (X:\mp3_collection).
This script only checks the drive letter and changes it. It will not update
folder names - only drive letters.

Without using the Pal.LockExecution and Pal.UnlockExecution commands, this script
will take 6 seconds to execute for every file in your database. A library of 4000
songs will take about 6 1/2 hours to go through at this rate. I suggest that those
of you with large collections uncomment the Pal.LockExecution and
Pal.UnlockExecution commands to speed up this script. However it may severely
affect the performance of your SAM while it runs. Be warned!

THERE ARE 3 PLACES YOU MUST MAKE CHANGES IN THIS SCRIPT.
Line 41 - change one variable
Line 42 - change one variable
Line 72 - uncomment this line when you are sure the script is working

}

PAL.Loop := False;
   var
     D : TDataSet;
   var
	    songID, position: Integer;
  var
	    old_filename, new_filename, old_drive, new_drive : String;
	    
	    
{ **********  edit this ****************************************************** }

old_drive := 'X';     // Change the letter to the drive you moved FROM
new_drive := 'Y';     // Change the letter to the drive you moved TO

{ **************************************************************************** }	
	    

  // Get all song ID's and filenames from database
  D:=Query('SELECT ID, filename FROM songlist', [], True);

// Pal.LockExecution

D.First;

While Not D.EOF Do
Begin
	songID := D['ID'];
	old_filename := D['filename'];
 position := Pos(old_drive, old_filename);

	IF position = 1 THEN
		Begin
		new_filename := old_filename;
  SetCharAt(new_filename, 1, new_drive);

		// Save new filename to database

  { The change to your database will not be made until you uncomment the next
  line. I suggest you run the script once and watch the results to the right to
  see what happens. Once you are confident that changes are being made correctly
  go ahead and uncomment the next line so that your database will be updated }
  
//  ExecSQL ('UPDATE songlist set filename = :new_filename WHERE ID = :songID', [new_filename, songID]);


  WriteLn ('Changing ' + old_filename);
  WriteLn (' to ' + new_filename);
		End;
	 D.Next;
End;

// Pal.UnlockExecution
D.Free;

Personal tools