Solved

AppleScript Repeat Not Working

Posted on 2013-01-31
3
519 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Deploystudio is a system which can be used to deploy OSX clients and servers within the small/medium or large business environments. The system is built onto of the OSX Server NetBoot system and uses images & workflows as its core assets. While work…
A lot of new and distinct gadgets are making their appearance every other day. The latest gadget that has wooed the attention of all gadget lovers and non gadget lovers alike is the Smartwatch. This tiny gadget is capable of offering live access to …
Users will learn how resize a batch of photos from a single command in Photoshop via Photoshop's Image Processor. Open up an Image you'd like to resize in Adobe Photoshop: Adjust the image size according to your preferences. Image > Adjustments > …
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…

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now