Repeating Problem - MacScript Tutorial

Hi I am trying to write a script to read the library of iTunes and print out a list of the titles that comply with the conditions. This is part of a tutorial I am going through. It is called AppleScript for Beginners IV - Records & Repeats


tell application "iTunes"
      set the_No_Beatles_List to every track of library playlist 1 whose duration is greater than 3600 and duration is less than 5000 and artist does not contain "Beatles"
      set itunes_Records_No_Beatles to {}
      repeat with a_Track in the_No_Beatles_List
            set end of itunes_Records_No_Beatles to {TrackName:a_Track's name, TrackArtist:a_Track's artist, TrackAlbum:a_Track's album, TrackRating:((a_Track's rating) / 20)}
      end repeat
      
end tell

I know there is more than one list because the first track that comes up starts with the name Rick if I put that in the place of the name Beatles (so as to not cotain it in the list) I get the next track which is Andrew. So for some reason it isn’t looping through the library. Please help me to know what is wrong. I am on Mountain Lion 10.8.

Thanks I am new to AppleScript

Randal

Model: MacBook Pro
AppleScript: 2.2.3
Browser: Firefox 18.0
Operating System: Mac OS X (10.8)

Hi. Unless these are some very long pieces of music, I think your durations may be one digit too long. :slight_smile:

set sansBeatles to {}

tell application "iTunes" to repeat with aTrack in (tracks whose duration is greater than 360 and duration is less than 500 and artist does not contain "Beatles")
	set sansBeatles's end to {TrackName:aTrack's name, TrackArtist:aTrack's artist, TrackAlbum:aTrack's album, TrackRating:((aTrack's rating) / 20)}
end repeat

sansBeatles

Thanks for getting back to me.

I don’t really have any music. They are all podcasts at least 2 hours or more. I ran your script and nothing showed up as matching the criteria.

When I change the durations to what I had it took 3 minutes but it churned out all the tracks in my library that met the criteria.

I noticed at the end of your script you specified the variable sansBeatles is that what caused it to display the entire listing as opposed to just one entry?

Anyway, thanks for getting me a script that works.

Ah, okay. I was moving the numbers in the wrong direction. If your podcasts exceed two hours, 5000 is actually too short; 7200 seconds is two hours.

Edit: I just missed your edited post. Yes, the value returned is from the last operation. If your list is the last value, its entire contents is returned.