Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I would like to add the release date to podcasts that I've imported into iTunes, but my applescript is returning an error about the date object.

    tell application "iTunes"
    set theSelection to selection
    if theSelection is not {} and (length of theSelection) is 1 then
        set theTrack to item 1 of theSelection
        log release date of theTrack as text
        set release date of theTrack to date ("2011-12-23T08:00:00Z" as string)

        refresh theTrack
    end if
end tell

The line set release date of theTrack to date ("2011-12-23T08:00:00Z" as string) gives me this error

error "Invalid date and time date 2011-12-23T08:00:00Z." number -30720

How do I make the string 2011-12-23T08:00:00Z into a date object that applescript won't complain about?

share|improve this question
    
Ok the property is read-only, so I'll have to use something like Subler. –  joshu Feb 16 '12 at 14:29

2 Answers 2

Unfortunately, it is not possible to change the "release date" tag within iTunes using Applescript because the property is read-only.

share|improve this answer

The string-to-date conversion depends on your locale settings (section "Formats" of "Language & Text" Preference pane in Snow Leopard), and you can also examine the format by executing the output of AppleScript command current date.

However, there's a way of making date initialization in AppleScript locale-independent (and thus portable):

set d to current date -- initialize new date object
set {year of d, month of d, day of d, time of d} to {2011, 12, 23, 8 * hours + 13 * minutes + 39} -- the last number is seconds
-- d is now set to 2011/12/23 08:13:39
share|improve this answer
    
by the way: if you want to always supply the date as text in a specific format, you could use a parser such as this one: gist.github.com/1852783 –  fanaugen Feb 17 '12 at 11:24
    
thanks, but I won't be able to use applescript after all. Please see my answer. –  joshu Feb 18 '12 at 17:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.