• 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
Re: itunes and duplicating track from library
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: itunes and duplicating track from library


  • Subject: Re: itunes and duplicating track from library
  • From: "David A. Cox" <email@hidden>
  • Date: Mon, 15 Nov 2004 14:39:03 -0800 (PST)

As always, Mr. Tea is spot on with the answer.

As long as the thread is open, I might as well toss out that this has now led me to another stumbling block (I thinK I just don't really get how iTunes does things). I would (after converting the file and adding the converted file to a new playlist), like to delete the original file from the library, all playlists, and the OS itself.

I tried a simple delete command, but that only takes the file out of the playlist it is being listed from (ie the pointer is removed). Trying to delete the "location" of the file results in an error that the file does not understand the delete command.

So, is there a way to easily delete a file that you have listed in a playlist from iTunes and the OS?

Below is the script that only deletes the file from the original playlist, not from the iTunes library or OS

--*****
tell application "iTunes"
convert track 1 of playlist "AIFF" returning fixedtracklist
set fixedtrack to location of item 1 of fixedtracklist
add fixedtrack to playlist "AAC"
delete track 1 of playlist "AIFF"
end tell
--*****

DAC

On Mon, 15 Nov 2004, Mr Tea wrote:

This from David A. Cox - dated 15/11/04 5ยท31 pm:

*****
tell application "iTunes"
convert track 1 of playlist "AIFF"
set fixedtrack to result
duplicate fixedtrack to playlist "AAC"
end tell
*****

but when I run the script, I get an error back of the form:

iTunes got an error: Can't set playlist "AAC" to {file track id 732 of
library playlist id 40 of source id 39}.


Note that the item 'file track id 732 [etc]'  is enclosed within braces,
which makes it a list (of one item). You have to extract the track from the
list to do what you need with it. Also, you should be using 'add' from the
iTunes suite rather than 'duplicate' from the Standard suite to add the
track to the desired playlist. This requires an alias rather than an
internal reference full of ids, but you can get that easily enough by asking
for the location of the track. The following should do what you need...

--*****
tell application "iTunes"
   convert track 1 of playlist "AIFF"
   set fixedtrack to location of item 1 of result
   add fixedtrack to playlist "AAC"
end tell
--*****

Here's a slightly different version that writes the result of the convert
operation to a variable in the same line.

--*****
tell application "iTunes"
   convert track 1 of playlist "AIFF" returning fixedtracklist
   set fixedtrack to location of item 1 of fixedtracklist
   add fixedtrack to playlist "Wake up call"
end tell
--*****

I generally prefer this approach because it grabs the result at the earliest
possible opportunity. I may just be being superstitious though.


HTH


Nick pp Mr Tea

--


_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: itunes and duplicating track from library
      • From: Mr Tea <email@hidden>
References: 
 >Re: itunes and duplicating track from library (From: Mr Tea <email@hidden>)

  • Prev by Date: Re: itunes and duplicating track from library [erratum]
  • Next by Date: Re: AS for MySQL
  • Previous by thread: Re: itunes and duplicating track from library [erratum]
  • Next by thread: Re: itunes and duplicating track from library
  • Index(es):
    • Date
    • Thread