Script to check if a file exists

Hi,

We have a database that has some number form where the original (mp3) file is missing. i’m trying to create a script that will check if a file is playable and if not mark that file. For now I create a short script that should detect these files but does not work.

[code]var
currentItem: IPlaylistItem;
i, iItemCount, iMax: integer;

begin
iItemCount := CurrentPlaylist.GetCount;
iMax := iItemCount - 1;

for i := 0 to iMax do	
begin
	currentItem := CurrentPlaylist.GetItem(i);
		if currentItem.ErrorCheck then
		begin
			SystemLog(currentItem.GetTitle);
		end;
	
end;

end.

[/code]

Only currentItem.ErrorCheck is not working and giving a type mismatch even according to the documentation it should be a boolean.

How could I check a playlist for entries with files that don’t exist?

Thanks!

Just use the ErrorCheck method of the Playlist.

It expects two parameters: An empty IStrings object in which it collects any error and warning messages, and an IProgressIndicator object - you can set the latter to “nil” as you cannot display any progress bar in a script.

var
  errors: IStrings;
  i: integer;

begin
  errors := Factory.CreateStrings;
  CurrentPlaylist.ErrorCheck(errors, nil);
  // now errors contains the error messages
  for i := 0 to errors.GetCount - 1 do
    SystemLog(errors.GetItem(i));
end.

This is actually the same function as invoked by right click -> This Playlist -> Error Check.