• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Deleting Tracks in iTunes
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Deleting Tracks in iTunes


  • Subject: Deleting Tracks in iTunes
  • From: Dave <email@hidden>
  • Date: Thu, 27 Nov 2008 15:26:22 +0000

Hi,

I'm trying to write a script to delete tracks from iTunes if they are not used in any user playlists, e.g. only appear in the "Music" playlist of iTunes. Please see the Script below. I added the repeat loop to look at the "track" item returned, the log looks like this:

(*3*)					-Track Count
(*file track id 202792*)
(**)						- Null Item
(*file track id 203012*)

The problem is that a track item is being returned as null. If I discount the null entries, the count if correct and my script works ok, otherwise the count is out. My question is, how can I get:

set myTrackList to (every track whose persistent ID = myPersistentID) of every user playlist of source mySourceIndex

to only return non-null track entries, or alternatively how can I detect a null entry?

Thanks in Advance
All the Best
Dave

Here is the Script:

tell application "iTunes"
set mySourceIndex to 5
set myPersistentIDList to {"c7a7b5dcd22c1733", "c7a7b5dcd22c1738", "c7a7b5dcd22c173d", "c7a7b5dcd22c1742", "c7a7b5dcd22c1749", "c7a7b5dcd22c16f7", "c7a7b5dcd22c171b"}
set myStatusList to {}

repeat with myPersistentID in myPersistentIDList


------------------------------------------------------------------------ ---
--
-- Added this to help find the problem -------------------------------
--
set myTrackList to (every track whose persistent ID = myPersistentID) of every user playlist of source mySourceIndex
log the number of items in myTrackList
repeat with myTrackRecord in myTrackList
log myTrackRecord
end repeat


------------------------------------------------------------------------ ---

set myTrackCount to the count of (every track whose persistent ID = myPersistentID) of every user playlist of source mySourceIndex
if myTrackCount = 1 then
try
delete (the first track whose persistent ID = myPersistentID) of playlist "Music" of source mySourceIndex
set myStatus to "OK"
on error
set myStatus to "ErrDelete"
end try
else
set myStatus to "NotDeleted:" & myTrackCount & ":" & (myPersistentID) & ":" & (the name of (the first track whose persistent ID = myPersistentID) of playlist "Music" of source mySourceIndex)
end if
set the end of myStatusList to myStatus
end repeat
end tell


return myStatusList


_______________________________________________ Do not post admin requests to the list. They will be ignored. AppleScript-Users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden
  • Prev by Date: Remote Desktop copy to me task
  • Next by Date: Re: AppleScript-Users Digest, Vol 5, Issue 629
  • Previous by thread: Remote Desktop copy to me task
  • Next by thread: Re: AppleScript-Users Digest, Vol 5, Issue 629
  • Index(es):
    • Date
    • Thread