A script for deleting all track numbers / album names

Discussion in 'MPTagThat' started by djdinjo, April 4, 2011.

  1. djdinjo

    djdinjo New Member

    Joined:
    April 4, 2011
    Messages:
    3
    Likes Received:
    1
    Ratings:
    +2 / 0
    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 (Text):
    1.  
    2. public class Script : IScript
    3. {
    4.   public bool Invoke(List<TrackData> tracks)
    5.   {
    6.     if (tracks == null) return false;
    7.  
    8.     // Loop through all Music Tracks and perform the necessary action
    9.     foreach (TrackData track in tracks)
    10.     {
    11.         // Delete the album name
    12.         track.Album = null;
    13.                 track.Changed = true; // Indicate that the track has been changed
    14.     }
    15.     return true;
    16.   }
    17.  
    18.   public string Invoke(TrackData track)
    19.   {
    20.     return "";
    21.   }
    22. }
    23.  



     
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. hwahrmann
    • Team MediaPortal

    hwahrmann Development Group

    Joined:
    September 15, 2004
    Messages:
    4,489
    Likes Received:
    1,621
    Gender:
    Male
    Location:
    Vienna, Austria
    Ratings:
    +2,246 / 1
    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 (Text):
    1.  
    2.     public string Artist
    3.     public string ArtistSortName
    4.     public string AlbumArtist
    5.     public string Album
    6.     public string AlbumSortName
    7.     public int BPM
    8.     public string Comment
    9.     public string CommercialInformation
    10.     public bool Compilation
    11.     public string Composer
    12.     public string Conductor
    13.     public string Copyright
    14.     public string CopyrightInformation
    15.     public string Disc
    16.     public string EncodedBy
    17.     public string Interpreter
    18.     public string Genre
    19.     public string Grouping
    20.     public string InvolvedPeople
    21.     public string Lyrics
    22.     public string MediaType
    23.     public string MusicCreditList
    24.     public string OfficialAudioFileInformation
    25.     public string OfficialArtistInformation
    26.     public string OfficialAudioSourceInformation
    27.     public string OfficialInternetRadioInformation
    28.     public string OfficialPaymentInformation
    29.     public string OfficialPublisherInformation
    30.     public string OriginalAlbum
    31.     public string OriginalFileName
    32.     public string OriginalLyricsWriter
    33.     public string OriginalArtist
    34.     public string OriginalOwner
    35.     public string OriginalRelease
    36.     public string Publisher
    37.     public int Rating
    38.     public string SubTitle
    39.     public string TextWriter
    40.     public string Title
    41.     public string TitleSortName
    42.     public string Track
    43.     public string TrackLength
    44.     public int Year
    45.  
     
  4. djdinjo

    djdinjo New Member

    Joined:
    April 4, 2011
    Messages:
    3
    Likes Received:
    1
    Ratings:
    +2 / 0
    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.
     
  5. sgatke
    • Premium Supporter

    sgatke MP Donator

    Joined:
    January 12, 2009
    Messages:
    76
    Likes Received:
    2
    Ratings:
    +2 / 0
    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.
     
  6. djdinjo

    djdinjo New Member

    Joined:
    April 4, 2011
    Messages:
    3
    Likes Received:
    1
    Ratings:
    +2 / 0
    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 (Text):
    1. track.Album = null
    to
    Code (Text):
    1. track.Album = ""
    For your Problem: Use this script:
    Code (Text):
    1. // Title: Delete Track No.
    2. // Description: This script deletes the Track No.
    3. //
    4. // ------------ Don't change anything in the following block -------
    5. //css_ref bin\taglib-sharp.dll;
    6. //css_ref MPTagThat.Core.dll;
    7. using System;
    8. using System.Collections.Generic;
    9. using MPTagThat.Core;
    10. using TagLib;
    11. // ----------------------------------------------------------------
    12. // Insert any using here that your script might need
    13. // If referencing an external dll, whose assembly name is not the same
    14. // as in the using, you need to insert a css_ref comment pointing to the dll.
    15. // See the example how taglib-sharp.dll is referenced on top of this file.
    16.  
    17. public class Script : IScript
    18. {
    19.   public bool Invoke(List<TrackData> tracks)
    20.   {
    21.     if (tracks == null) return false;
    22.  
    23.     // Loop through all Music Tracks and perform the necessary action
    24.     foreach (TrackData track in tracks)
    25.     {
    26.         // Delete Track No.
    27.         track.Track = "";
    28.         track.Changed = true; // Indicate that the track has been changed
    29.     }
    30.     return true;
    31.   }
    32.  
    33.   public string Invoke(TrackData track)
    34.   {
    35.     return "";
    36.   }
    37. }
    38.  
    I hope it helps. I tested it and it works.
     
    Last edited: August 26, 2012
    • Like Like x 1
    • Thank You! Thank You! x 1
  7. sgatke
    • Premium Supporter

    sgatke MP Donator

    Joined:
    January 12, 2009
    Messages:
    76
    Likes Received:
    2
    Ratings:
    +2 / 0
    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!
     
  8. hwahrmann
    • Team MediaPortal

    hwahrmann Development Group

    Joined:
    September 15, 2004
    Messages:
    4,489
    Likes Received:
    1,621
    Gender:
    Male
    Location:
    Vienna, Austria
    Ratings:
    +2,246 / 1
    Home Country:
    Austria Austria
    It should also work to mark all the files and then enter "0" in the Track Number field.
     
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!