Re: How do you add a track not currently in iTunes to iTunes playlist using applescript
Re: How do you add a track not currently in iTunes to iTunes playlist using applescript
- Subject: Re: How do you add a track not currently in iTunes to iTunes playlist using applescript
- From: has <email@hidden>
- Date: Tue, 8 Jan 2008 18:37:14 +0000
On 8 Jan 2008, at 17:33, Paul Taylor wrote:
Hi, complete novice trying to add a track not currently in iTunes to
iTunes playlist using applescript, I can get it to create a new
playlist -but cant see how to add track to playlist, this is what I
have so far
tell application "iTunes" to
set new_playlist to (make user playlist with properties {name:"New
Playlist"})
add track "/users/paul/Music/test.mp3" to playlist new_playlist
I see two errors, not counting the dubious-looking 'tell' block:
1. The 'add' command takes an alias or POSIX file object (or a list of
alias/POSIX file objects) identifying the file(s) you want to add as
its direct parameter. e.g.:
alias "MacHD:Users:paul:Music/test.mp3"
{POSIX file "/users/paul/Music/test.mp3", POSIX file "/users/paul/
Music/test2.mp3", ...}
Note that 'track "/users/paul/Music/test.mp3"' is not a valid alias/
POSIX file specifier. Nor is it a valid iTunes track specifier, which
is why iTunes throws an error when it tries to use it.
2. The 'add' command takes a playlist reference as its optional 'to'
parameter. Your 'new_playlist' variable already contains a valid
playlist reference which you should pass as-is, i.e.:
add ... to new_playlist
Attempting to use that playlist reference in an object specifier -
e.g. 'playlist new_playlist' - will produce an invalid reference, and
iTunes will throw an error when it tries to use it.
Here is the corrected version of your code:
tell application "iTunes"
set new_playlist to (make user playlist with properties {name:"New
Playlist"})
add (POSIX file "/Users/has/Music/WoTW/wowa.mp3") to new_playlist
end tell
HTH
has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
_______________________________________________
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