AppleScript to determine album ratings from song ratings and no. of tracks?

Hi
I am wondering if it would be possible to write an AppleScript to determine the album ratings for my albums in iTunes in the following way:
All of my music collection comes from CDs I have ripped. I rip the whole album and then delete tracks I don't like. The number of tracks in the original album is preserved in the Track # field, e.g. Track 1 of 10, etc. All multi disc albums have been given the same name, i.e. they are recognised as the same album with Disc Number preserved, i.e. Disc #1 of 2, etc.
The Album Rating would then be the sum of the rating of every song that is still in my iTunes Music Library divided by the total number of tracks in the original album (with multi disc albums counted as one album).
So, for example, if I had an one disc album which originally had 10 tracks, that I only kept two songs from, and one of these tracks had a rating of 5 and the other 3, the album rating would be as follows:
5+3/10 = 0.8
Ideally this value would then be written to the Album Rating tag in iTunes. I think the best iTunes can do is display half-star ratings, but I wonder if it will still sort the Albums by Album Rating based on the actual value of the above calculation, i.e. an album with Rating 4.52 would be sorted higher than an album with rating 4.48, but both would show in iTunes as having 4 and a half stars?
The next best option would be for the script to generate a text file of the Album Ratings sorted by rating with the highest first (in fact it would be good to have this in addition to the values being written to the Album Rating tags)
The difference between this script and the built in method used in iTunes is that iTunes doesn't account for deleted tracks, so in the above example the Album would be rated 4, even though 8 tracks had been deleted.
I hope this is clear and would be grateful for any help in getting this script together.
Thanks,
Nick.

Here's an improved version of the script that should fulfill your needs (the modifications are in blue). The script now sorts the Album Ratings (via Numbers.app) and save them to a text file on the desktop, with no rating greater than 80. As previously, you must choose at least one track.
--BEGINNING OF SCRIPT
*tell application "iTunes"*
--Make a list of all the selected albums:
*set theAlbums to {}*
*set theAlbumsRef to a reference to theAlbums*
*set tempList to album of selection*
*set thePreviousTitle to ""*
*repeat with thisTitle in tempList*
*set thisTitle to thisTitle as text*
*if thisTitle is not thePreviousTitle then*
*copy thisTitle to the end of theAlbumsRef*
*set thePreviousTitle to thisTitle*
*end if*
*end repeat*
*set numberOfAlbums to count theAlbums*
--Make a list containing one track for each selected album:
*set theTracks to {}*
*set theTracksRef to a reference to theTracks*
*repeat with thisAlbum in theAlbums*
*copy (track 1 whose album is thisAlbum) to the end of theTracksRef*
*end repeat*
--Set the album rating of each album contained in the selection:
*set theRatings to ""*
*set k to 0*
*repeat with thisTrack in theTracks*
*set k to k + 1*
*if k mod 25 = 0 then beep 1* -- for audio feedback
*set thisAlbum to item k of theAlbums*
*set numberOfTracks to 0*
*repeat with k from 1 to (disc count of thisTrack)*
try
*get (track count of track 1 whose (album is thisAlbum) and (disc number is k))*
*set numberOfTracks to numberOfTracks + result*
*end try*
*end repeat*
*set songRating to 0*
*repeat with R in (rating of tracks whose album is thisAlbum)*
*if R > 80 then set R to 80*
*set songRating to songRating + R*
*end repeat*
*set thisRating to round (songRating / numberOfTracks)*
*set album rating of thisTrack to thisRating*
*set theRatings to theRatings & (album artist of thisTrack & tab & thisAlbum & tab & (thisRating as text) & return)*
*end repeat*
*end tell*
--Save the album ratings to a text file (on the dekstop):
*set theTextFile to POSIX file (POSIX path of (path to desktop) & "iTunes Ratings")*
*open for access theTextFile with write permission*
*set eof theTextFile to 0*
*write theRatings to theTextFile*
*close access theTextFile*
--Use application Numbers.app to sort the text file by rating:
*tell application "Finder" to set NumbersWasOpen to (process "Numbers" exists)*
*tell application "Numbers"*
launch
*open theTextFile*
*tell table 1 of sheet 1 of front document*
*sort by column 3 direction descending*
*set theSortedRatings to ""*
*repeat with j from 1 to numberOfAlbums*
*set X to value of cell 1 of row j*
*if X = 0 then set X to ""*
*set Y to value of cell 2 of row j*
*if Y = 0 then set Y to ""*
*set Z to (value of cell 3 of row j) as integer*
*set theSortedRatings to theSortedRatings & X & tab & Y & tab & Z & return*
*end repeat*
*end tell*
*close front document without saving*
*if not NumbersWasOpen then quit*
*end tell*
*open for access theTextFile with write permission*
*set eof theTextFile to 0*
*write theSortedRatings to theTextFile*
*close access theTextFile*
theSortedRatings
--END OF SCRIPT
Please let me know if anything doesn't work as expected.
Message was edited by: Pierre L.

Similar Messages

  • Error when determining a number from object BI_TSDTEL and number 01

    Hi BW Experts,
    After Transporting Infosources (Master & Transaction) to BW QA, the transfer rules were not getting activated in QA. The following error message was diaplyed.
    "Error when determining a number from object BI_TSDTEL and number 01
    Object name can only contain characters from syntactical character set
    Object name can only contain characters from syntactical character set
    Data element for InfoObject KOKRS 0CO_AREA could not be created
    Data element for InfoObject KOKRS 0CO_AREA could not be created
    Transfer structure 0IM_FA_IQ_2_SB activated under the name 0IM_FA_IQ_2_SA
    It is not necessary to copy dependent objects for transfer structure 0IM_FA_IQ_2_SA
    Transfer structure 0IM_FA_IQ_2_SA does not exist
    Error RSAR 440 when handling objects with type R3TR ISTS."
    I have gone through the Note: 674818.
    Could someone clear me about BI_TSDTEl, By using this do we need to maintain object intervals manually in all the systems like BW ( Dev & QA ), R/3 (Dev & QA).
    Because  I have not seen the Intervals in R/3 ( Dev & QA) systems.
    please could someone provide Inputs for this.
    Thanks in Advance
    Regards
    SK

    Hi,
    Try to see that transfer structure is existing in the sytem which is connecting in
    the BW quality.
    You need the same to be transported from the development server of R/3 to quality server of R/3.
    Just check if this helps.
    Regards
    Rahul Bindroo

  • Album ratings and clear stars are ruining my playlists. Help turn them off.

    I understand that if you give an album an album rating, it will give all unrated songs on that album clear stars based on the album rating. Because of this, I have not rated any of my albums, since all of my playlists are based off of the song ratings.
    All of a sudden, now when I rate a single song, it puts clear stars in the album rating column, and ALSO assigns clear stars for all of the unrated tracks on that album. It is ruining all of my playlists.
    Is there any way to turn off the album ratings, or turn off the clear stars, or do something to get rid of this, rather than going through manually and adjusting each song individually?

    Is there anyway to make itunes recognize the difference between clear stars and filled stars when making smart playlists? This may work to make things work for me.
    If you use "album rating" field in your playlist, it will use the clear stars that appear in that column. If you use "rating" field in your playlist, it should ignore the clear stars that appear in the "album rating" column.
    As for an example of how things are not working right now, I have a playlist that is just unrated music, so that if I feel like rating some of the newer songs I added in, I can just load that playlist, and everything in there has no ratings. Now, some of the albums that are mostly unrated are not showing up in that playlist, because instead of all of the unrated songs being blank, they all have clear stars next to them.
    When you say "unrated music", what precisely is the rule you use? When I set up a playlist with the rule "Rating is less than '1 star'", even albums with clear stars in the "album rating" field show up (as long as the individual track doesn't bear a rating, obviously). But when I change that rule to say "Album rating is less than '1 star'", then as soon as I rate one song, the entire album is removed from the playlist.
    And just to make sure I am being very clear on this, I have NOT used the album rating at all, those stars are clear as well.
    Ok, I think this may answer some of the questions in my previous post. I infer that you are seeing clear stars in the "rating" column, not just the "album rating" column. Can you confirm this? If that's the case, then this is truly a mystery. I was hoping the problem was an innocent confusion between the "album rating" and the "rating" columns.

  • Album ratings and smart playlists

    Hello all,
    I was wondering if anyone can help me with the new iTunes functionality. I am trying to create a smart playlist with album ratings between 0 stars and 5 stars (basically all albums) and limit the playlist to 4 gb. I am trying to just create a random list of albums to sync to my iphone. Everytime I create a random list it always truncates the final album to exactly match 4gb so there is always an album that is incomplete.
    Can anyone think of a different way to accomplish this so you can get ALL complete albums? There must be a way. Sorry if I sound picky about this but I am an album guy, not a random song guy.

    Hi there. Try the following:
    iTunes -> Preferences... -> Playback -> Shuffle: Albums
    Now take your smart playlist you created, and set the 4GB limiter selected by "random" instead of "album". Because we forced shuffling to be by album only, this "random" will select entire albums, randomly. I just figured this out a few minutes ago and it seems to work great.
    If you want all albums, you can probably omit the album rating rule (you might need to set Kind to "MPEG audio file" or something to skip podcasts, etc.)
    To refresh your list, select and delete all tracks in the playlist, or use the Reshuffle Smart Playlists script available at dougscripts.com/itunes. Or you could add a criterion saying that Last Played must be greater than a month, or so.

  • How can I remove "Album Artwork" from my iPhone and iPad?

    I've posted about this before in other threads, but the silence from Apple has been deafening,  Others in the community have agreed with the request but haven't been able to answer it.
    I thought a thread of its own might get attention, since Apple won't talk to me otherwise.
    I use music on my iPhone and iPad a lot, playing through speakers in my study or through the car system.  It worked well at first, until I updated the operating systems.
    Now, where I used to have a list of albums, music, or playlists I have large blank areas where album artwork would go if there were any - which in most cases there isn't.  The iPad used to display 50 or more playlists in one screen,with some details of them.  Now, it shows 15 blank squares with a crotchet on them, and the name of the playlist.  That really isn't much use.
    PLEASE PLEASE PLEASE can there be a way to turn OFF album artwork on the iPhone and iPad?   It wastes an enormous amount of screen space for stuff I don't have and don't want.   It's a very unwelcome new "feature" (ie "bug"). 

    Keithjillings wrote:
    (Sic), but the silence from Apple has been deafening,
    I thought a thread of its own might get attention, since Apple won't talk to me otherwise.
    Apple does not participate in these forums, so that would explain why you have not received a response.
    I am not aware of a way to turn off Album art on the devices. If you want to let Apple know of your desire for this setting, go to www.apple.com/feedback and click on the appropriate link. That is where you communicate with them. They will receive the feedback, however they do not respond to it.

  • Art for album different from songs art

    Windows 7, iTunes 11.4. I'm looking at the "show album art" view. It's showing the wrong album art for an album, but when I right click on a song and click "get info", that window shows the right art. Hitting next for each next song shows the right art. The album as a whole has the wrong art. How do I fix this?

    Can anyone please answer my question?

  • TS1474 Lost several albums *completely* from iTunes library AND iPod-HELP

    Sooo I had been using my laptop for iTunes purchases, management, etc., and then the thing crashed and has never been revived. I decided to begin using the desktop computer to access iTunes instead, and in the process of syncing a new purchase to my iPod, somehow inadvertently lost several older albums that I had purchased earlier. Now when viewing my library on either iPod or iTunes library on desktop computer, they do not appear to be present. Are they truly gone? All that money spent..poof? Please advise!

    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        
    It appears that the mess resulted in the iPod seeing the computer/iTunes library as a new computer/iTunes library. If you sync to a new computer your iPod gets erased and the media in the iTunes library ends up on the iPod.

  • How Can I Delete All Album Art From My Computer and Cache

    Hi,
    Having problems with my album artwork and cannot seem to be able to delete it and it is also applying itself  (one same cover) across many albums.
    What files extension can i seach for and delete so I can start with a clean slate?
    Cheers

    HI this issue was indirectly solved on another thread by turingtest2..
    https://discussions.apple.com/thread/4742491?tstart=0

  • Lost library, ratings and versions since installing on second computer

    Hi, I recently installed aperture 3 on my secondary computer, no issues. But when I went on aperture on my primary computer before it opened it asked to perform update to library, now I have lost all albums, ratings and variations i've created since mid 2009! This is when i originally upgraded from aperture 2.0 to aperture 3. The master images are still on my external hard drive, but i have lost all the work i've done on them over the last 4 years. Any help much appreciated.

    Hi, in answer to your questions:
    On the old computer which shipped with aperture 2 pre-installed it was running on aperture 3 which i updated to back in mid 2009.
    On the secondary mac i tried installing aperture through the aperture 3 upgrade disk, which then asked me for the original serial number, I requested this from apple (as it was pre-installed) and put that in and then it went onto install apperture 3 on the secondary mac. It installed fine on the secondary computer
    The problem occured when i went to use aperture on the old mac, that's when it said it needed  to update the library. It all opens fine, but what is missing is any data from mid 2009 onwards (when aperture 2 was upgraded to aperture 3. I can still manually import the masters again, but what i'm missing is all the albums, editing, rating and different versions of images i have created since mid 2009.
    I've searched for any other libraries on my system or external drives there are a few, but all look older and contain less data than the one i am using now.
    I'm at a loss and quite worried that i've lost all that data for ever after pressing the update library button.

  • Changing song names and adding album artwork

    Some of the songs that i imported into itunes by some artists, lets say for example "Less Than Jake" shows up as "less than jake" (uncapitalized) when i go to change the first letter which is an "l" to a capital "L" i successfully change the name in itunes and then when i am done changing ti and click on another song it just goes back to lower case
    does anyone know how to fix that so that the names that i fix stay fixed not just go back
    Another question that i have is some of my artists albums do not have album artwork and when i right click on the album and say get album artwork nothing happens. And i already registered with itunes store so its not that it wont get the album artwork because i didn't register with itunes. Is there anyway to copy the album picture from the internet and get it associated with that specific album in itunes anyway?
    ANY HELP WOULD BE GREATLY APPRECIATED
    THANKS IN ADVANCE
    GREG
      Windows XP Pro  

    Greg,
    Are you just typing over the name as it appears in your iTunes library?
    I am not familiar with the Windows version, but in the Mac version, the best way to edit song title/artist/genre, etc is to select a song and then "Get Info" - in the Mac version that is under the "File" menu - a right click will probably work for you. There are several tabs on the Get Info screen - go to the "Info" tab and you will see what to do.
    As for album artwork, iTunes has been pretty good about finding artwork for for those albums which I purchased from the iTunes store, but was no help at all in finding art for the (many) albums I ripped from my CDs.
    You COULD find the album art yourself, using Google 'Images' but I think you will find it to be too tedious, and most of the album cover JPEGs you will find by that method are too small and of poor quality.
    It would be better to use a third party application. For Mac users I can recommend Fetch Art (http://members.cox.net/afriesen3//fetchart/index.html); I expect there is something similar for Windows, but I can't be specific.
    -GW

  • Error when determining  a number from object BI_ODS

    Error When determining a number from object BI_ODS and number 01  when flat file source system is assigned to transfer rules of infosource , when activating this error occured .
    plz need solution.

    Hi,
    Number ranges can be maintained through the transaction SNRO. For details check:
    http://help.sap.com/saphelp_nw70/helpdata/EN/2a/fa02e3493111d182b70000e829fbfe/frameset.htm
    Rgds-
    Sonal

  • How can I add songs from my internal library to my external backup library without losing ratings and comments?

    Hi, I have some 30.000 Songs in my constantly growing internal library and another 25k in my external backup library. I noticed that I lost all my ratings when fusing my libraries the last time.
    As ratings and comments are essential for my work as a radio dj: How can I fuse libraries or add songs from my internal to my external library and keep ratings and comments and: How can I make sure, iTunes adds ratings and comments from songs I still have in my internal library to the same songs (without ratings and comments) in my external library? Thanks a lot for your help!

    I use http://decimus.net/Synk to keep my iMac's iTunes synchronized with the backup iTunes folder on an external disk.  Any changes I make are automatically synced to the backup.  You might find it useful.

  • Taking songs from ipod classic and putting them on new computer without deleting plays and ratings?

    Hi Guys
    I need help. My computer died and I now have a new one with my old iTunes on a external hard drive (EHDD) and on my Ipod Classic.
    When I copied all the music from my EHDD to the new computer it has put all the music on there but without any ratings or play count.
    Is there a way I can use the info on my ipod classic to update the play count and ratings?
    Also I'm scared to sync my ipod to the new iTunes because I don't want to loose these plays and ratings.
    What should I do?

    Hello Calumk4,
    After reviewing your post, I have located an article that can help in this situation. It contains a number of troubleshooting steps and helpful advice concerning transferring iTunes libraries:
    iTunes: Back up your iTunes library by copying to an external hard drive
    Consolidating Your iTunes library
    To make the move as easy as possible, it's important to make sure all of the items in your library are in one place.
    Open iTunes Preferences:
    Mac: Choose iTunes > Preferences.
    Windows: Choose Edit > Preferences.
    Click Advanced.
    Make sure the option to "Copy files to iTunes Media folder when adding to library" is selected.
    Click OK.
    Note: With this option selected, when you add files to iTunes, iTunes places copies of the originals in the iTunes Media folder. The original files are left in their original locations. To save space on your hard disk, you might want to delete the original files after confirming import.
    Choose File > Library > Organize Library.
    Select the option to "Consolidate files."
    Note: If you recently updated to iTunes 9, you might want to consider selecting the option to "Upgrade to iTunes Media organization." This updates the file organization of your iTunes Media folder.
    Click OK.
    Note: If you originally did not have the option to copy files enabled, iTunes will copy files outside of the iTunes Media folder from their original locations to the iTunes Media folder. To save space on your hard disk, you might want to delete the original files after confirming they have been moved and are backed up.
    Copy iTunes folder to your external hard drive
    To copy all the items in your iTunes library (including the iTunes Library file that holds all your playlists, playcounts, ratings, and other data) to your external hard drive, follow these steps:
    Quit iTunes.
    Locate your external hard drive.
    Mac: On the desktop or Finder sidebar.
    Windows: In My Computer
    Locate your iTunes folder:
    By default, the iTunes folder is located in:
    Mac OS X: /Users/username/Music
    Windows XP: \Documents and Settings\username\My Documents\My Music\
    Windows Vista: \Users\username\My Music\
    Windows 7 or 8: \Users\username\Music\
    If the iTunes folder is not in the default location listed above then you can find where the iTunes folder is located by following these instructions:
    Open your iTunes Preferences:
    Mac: Choose iTunes > Preferences.
    Windows: Choose Edit > Preferences.
    Click Advanced.
    The location of your iTunes folder will be listed in iTunes Media folder location box, as pictured below.
    Drag the iTunes folder to your external hard drive. This can take a while if you have a lot of items.
    When the transfer is complete, your iTunes Library will have been successfully copied to your external hard drive.
    Thank you for contributing to Apple Support Communities.
    Cheers,
    BobbyD

  • Album Ratings

    Every now and then while in iTunes I will notice that some of my songs have an assigned album rating, because I will see the regular song rating and it will have the weird "clear" stars, instead of the regular filled ones. This is really annoying and I was wondering if it could be turned off. Most of my playlists are based on song rating, and the album rating forces unrated songs on that album to be given a song rating, meaning these random songs then appear in my playlist, that is supposed to be only 4 star songs or higher.
    And before anyone says it, no I have not been assigning album ratings accidentally, because I purposely make sure the album rating column is not visible anywhere specifically so that this does not happen, as this is an issue I've had for several years. I've also gone through and mass-removed the album ratings from all songs a couple of times, so I know its not that the songs already had album ratings in their metadata when I obtained them, or any other silly excuse someone can come up with. I'm almost positive that it is iTunes somehow randomly doing this, or maybe its supposed to be happening, and it is just a poorly designed feature? Either way I really want it removed, because I'm tired of random songs appearing in my playlists, and I dont plan on rating every single song in my library to prevent this from occuring.

    I am aware of a feature where songs with no rating, belonging to an album WITH a rating, will receive an automatic song rating. That is not the issue I am describing. Ratings assigned by iTunes are represented with hollow stars, as you described. My issue involves songs in my library being assigned a manual album rating, with solid stars, as if I assigned them myself, when I did not.
    I am sure I have not done this accidentally - or anything like that - because, for this very reason, I have gone through my library - and all playlists - and made sure the Album Rating column was not visible. This means it is not possible for me to have assigned these album ratings myself. This is a continuous issue, as I have mass-removed all album ratings a couple times already.
    I am trying to navigate Apple's site to find a link to email customer service, but I am not having luck with that, as my issue doesn't really fit into any of the predisposed categories they have outlined, and I can't find a generic email link; So if anyone has any insight on this, that would be greatly appreciated.

  • Transfer Music Ratings and Playlists from iPhone 5c to Macbook Air iTunes

    Hi,
    My iPhone 5c used to sync with my old Windows laptop via iTunes and both devices held all music information on them such as iTunes rating, playlist information and the selected songs to be synced (there are more songs on my iTunes on my laptop than my iPhone).   All of these songs are also saved on an external hard drive.  None were purchased through iTunes.
    When my old Windows laptop died, it died abruptly so I did not have chance to consolidate the iTunes media folder.  I have now bought a new MacBook Air to replace my old Windows laptop.
    When I plug in my iPhone 5c to my new MacBook Air, when iTunes offers to sync it advises all information on my iPhone will be lost.
    Is it possible to transfer the ratings and playlists from my iPhone to iTunes on my MacBook Air, at least for the corresponding songs that exist on my iPhone?  Note I have the original songs on an external hard drive so the song files themselves do not have to copy across.  All the files in the iPhone exist in the external hard drive.

    Below are the steps about how to transfer playlist from iphone to itunes:
    Step 1: To create a playlist on your iPhone or other iOS device, open the Music app and then tap on Playlists at the bottom left of the screen. Once there, tap on Add Playlist… at the top of the screen. Here you will be prompted to name your new playlist. Enter a name and then tap on Save.
    Step 2: Each song will have a blue “plus” sign to its right. Tap on the sign next to each song to add it to your new playlist. When you finish choosing songs, tap on Done at the top right of the screen to finish creating your playlist.
    Step 3: Connect your iPhone to your Mac or PC either via a cable or wirelessly and click on it from the menu on the left pane.
    Step 4: From the tabs at the top of the iTunes Window, check the Sync Music option and also check the Selected playlists, artists, albums and genres. Then select the playlist you just created from the list below. To start syncing, click on the Apply button.
    Step 5: Syncing will then start and after it is complete, you will see that the playlist you just created on your iPhone is now also on iTunes under Playlists on the left pane of the iTunes window. Or vyou can use iPhone Transfer.

Maybe you are looking for