Solved

AppleScript Repeat Not Working

Posted on 2013-01-31
3
521 Views
Last Modified: 2013-02-06
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.

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 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,

Randal
0
Comment
Question by:sharingsunshine
  • 2
3 Comments
 
LVL 19

Assisted Solution

by:Kash
Kash earned 500 total points
ID: 38844067
i think you need to use LOOPS to repeat the search on the whole library >>> http://www.mactech.com/articles/mactech/Vol.20/20.12/RepeatLoops/index.html
0
 

Accepted Solution

by:
sharingsunshine earned 0 total points
ID: 38844156
Thanks for getting back to me but repeats will work.  I took the code above and after the repeat put in the name of the variable

itunes_Records_No_Beatles

then it showed all of the records that met the criteria.  But the site you gave me will help with some other issues so that's worth the points to me.  Incidentally, I googled extensively trying to find how to create a form in Applescrilpt and mactech never came up.  So I wouldn't have known about it if you hadn't mentioned it.
0
 

Author Closing Comment

by:sharingsunshine
ID: 38858701
repeats do work you just have to specify the variable after the repeats have reached the end of the data.
0

Featured Post

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The /etc/authorization file in Mac OS X 10.x can be used to control access to the various panes of the System Preferences amongst other things. It’s used by some of us Mac Sys Admin’s to give Standard Users access to System Prefs panes that only adm…
Syslogd is a utility that traps and logs messages sent by running processes. It is configured with the syslog.conf file, which consists of lines containing a pair of fields: "the selector field which specifies the types of messages and priorities to…
Users will learn how to set proper sequence settings, scale images, paste attributes, add transitions, fades, and music. Open up Final Cut Pro 7 and Create a new Project: Set the Sequence Settings. a) Click File > Easy Setup > Format > Apple ProRe…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question