A script for deleting all track numbers / album names (1 Viewer)

djdinjo

New Member
April 4, 2011
3
2
Home Country
Germany Germany
Hello.
I want to write a script on my own. The samples are documentation enough for me how to write one on my own.
So I tried the code you see in the bottom. It doesn't work. So I think, that the names for the TAGs (Album) is not right. What should I use instead of? And what should I use if I want th clear the Track number of a Track?
A short list with the most used TAG-names will be helpful to write some scripts on my own. I really want to do it on my own.

PS: :D a lot for the great work of this tool!

Code:
public class Script : IScript
{
  public bool Invoke(List<TrackData> tracks)
  {
    if (tracks == null) return false;

	// Loop through all Music Tracks and perform the necessary action
	foreach (TrackData track in tracks)
	{
		// Delete the album name
		track.Album = null;
                track.Changed = true; // Indicate that the track has been changed
	}
    return true;
  }
  
  public string Invoke(TrackData track)
  {
	return "";
  }
}
 

hwahrmann

Development Group
  • Team MediaPortal
  • September 15, 2004
    4,633
    2,457
    Vienna, Austria
    Home Country
    Austria Austria
    The script looks ok.
    What you may try is setting it to "" instead of null.

    btw, there is an easier way to clean the Album.
    Just Select all the rows and do a Multiple Tag Edit, clearing the Album Text field.

    Here are the properties, which you may use:

    Code:
        public string Artist
        public string ArtistSortName
        public string AlbumArtist
        public string Album
        public string AlbumSortName
        public int BPM
        public string Comment
        public string CommercialInformation
        public bool Compilation
        public string Composer
        public string Conductor
        public string Copyright
        public string CopyrightInformation
        public string Disc
        public string EncodedBy
        public string Interpreter
        public string Genre
        public string Grouping
        public string InvolvedPeople
        public string Lyrics
        public string MediaType
        public string MusicCreditList
        public string OfficialAudioFileInformation
        public string OfficialArtistInformation
        public string OfficialAudioSourceInformation
        public string OfficialInternetRadioInformation
        public string OfficialPaymentInformation
        public string OfficialPublisherInformation
        public string OriginalAlbum
        public string OriginalFileName
        public string OriginalLyricsWriter
        public string OriginalArtist
        public string OriginalOwner
        public string OriginalRelease
        public string Publisher
        public int Rating
        public string SubTitle
        public string TextWriter
        public string Title
        public string TitleSortName
        public string Track
        public string TrackLength
        public int Year
     

    djdinjo

    New Member
    April 4, 2011
    3
    2
    Home Country
    Germany Germany
    AW: A script for deleting all track numbers / album names

    Thank you.
    I always tried to edit multiple edits in the right part of the window and wondered that the Artist of the first selected is taken for all...
    But now I can experiment with the scripts. Thank you for the info.
     

    sgatke

    MP Donator
  • Premium Supporter
  • January 12, 2009
    76
    2
    Home Country
    Denmark Denmark
    Hi
    I am in a situation where I could use a script to clear track-numbers from all MP3 songs located in a particular folder.
    I have tried using the above script, but it does not seem to do anything at all when I execute it.
    When I try to execute, I have selected all the tracks.

    Would it be possible with a "walk-thru" or an example of how to accomplish this task?

    Thank you in advance.
     

    djdinjo

    New Member
    April 4, 2011
    3
    2
    Home Country
    Germany Germany
    Hi sgatke.

    Thanks for your question. It was long ago since I used the skrips the last time and I deleted all my written skrips on my old HTPC before I sold it. I'm also sorry that I didn't wrote the solution here. So, here are the results and the solution for your problem:

    For the script at the first thread: As hwahrmann told, the skript was ok. You have to change
    Code:
    track.Album = null
    to
    Code:
    track.Album = ""

    For your Problem: Use this script:
    Code:
    // Title: Delete Track No.
    // Description: This script deletes the Track No.
    //
    // ------------ Don't change anything in the following block -------
    //css_ref bin\taglib-sharp.dll;
    //css_ref MPTagThat.Core.dll;
    using System;
    using System.Collections.Generic;
    using MPTagThat.Core;
    using TagLib;
    // ----------------------------------------------------------------
    // Insert any using here that your script might need
    // If referencing an external dll, whose assembly name is not the same
    // as in the using, you need to insert a css_ref comment pointing to the dll.
    // See the example how taglib-sharp.dll is referenced on top of this file.
     
    public class Script : IScript
    {
      public bool Invoke(List<TrackData> tracks)
      {
        if (tracks == null) return false;
     
        // Loop through all Music Tracks and perform the necessary action
        foreach (TrackData track in tracks)
        {
            // Delete Track No.
            track.Track = "";
            track.Changed = true; // Indicate that the track has been changed
        }
        return true;
      }
     
      public string Invoke(TrackData track)
      {
        return "";
      }
    }

    I hope it helps. I tested it and it works.
     
    Last edited:

    sgatke

    MP Donator
  • Premium Supporter
  • January 12, 2009
    76
    2
    Home Country
    Denmark Denmark
    Perfect!
    THANK you very much for your quick answer. I have been looking for a (painless) way to do this for a long time, but never dared venture into scripting.
    The script works perfectly - thanks!
     

    Users who are viewing this thread

    Top Bottom