copia le voci del calendario da un calendario a un altro tramite lo script Apple genera un errore

1

Sto provando a copiare voci ical da un calendario all'altro usando il seguente script:

tell application "iCal"
    set localEvents to events of calendar "Privat"
    set remoteEvents to events of calendar "owncloud"
    repeat with theEvent in localEvents
        if theEvent is not in remoteEvents then
            copy theEvent to end of remoteEvents
        end if
    end repeat
end tell

genera il seguente errore, che non capisco:

error "«class wrev» id \"AEBA9736-5B3B-48D3-9DCA-80577709EAB5\" of
«class wres» id \"BAB254DB-3CC3-4383-B2E0-C8135EA5F65C\" of
application \"iCal\" kann nicht in Typ vector umgewandelt werden."
number -1700 from «class wrev» id
"AEBA9736-5B3B-48D3-9DCA-80577709EAB5" of «class wres» id
"BAB254DB-3CC3-4383-B2E0-C8135EA5F65C" to vector

che cosa significa e come posso far funzionare lo script?

    
posta mcnesium 15.03.2013 - 16:20
fonte

1 risposta

1

Questo è quello che ho finora. Tutto funziona bene, tranne il mio controllo in doppio. Appena ricevuta la dichiarazione tell per "Evento scartato: Vecchio". Quando questo non è il caso. Qualche aiuto?

to getRecurrenceTermination(startDate, recurrenceString)
set olddel to AppleScript's text item delimiters
set AppleScript's text item delimiters to ";"
set tItems to text items of recurrenceString
set AppleScript's text item delimiters to "="
set d to 0
set untl to missing value
repeat with anItem in tItems

    set parts to text items of anItem
    set sec to word 3 of anItem

    if (offset of "FREQ=" in anItem) > 0 then
        if (offset of "WEEKLY" in anItem) > 0 then
            set d to 7
        else if (offset of "DAILY" in anItem) > 0 then
            set d to 1
        else if (offset of "MONTHLY" in anItem) > 0 then
            set d to 31
        end if
    else if (offset of "INTERVAL=" in anItem) > 0 then
        set d to d * sec
    else if (offset of "COUNT=" in anItem) > 0 then
        set d to d * sec
    else if (offset of "UNTIL=" in anItem) > 0 then
        set untl to current date
        set untl's year to text 1 thru 4 of sec
        set untl's month to text 5 thru 6 of sec
        set untl's day to text 7 thru 8 of sec
        set untl's hours to text 10 thru 11 of sec
        set untl's minutes to text 12 thru 13 of sec
        set untl's seconds to text 13 thru 14 of sec
    end if
end repeat
set AppleScript's text item delimiters to olddel

if untl is missing value then
    if d is not 0 then
        set finalDate to startDate + (d * days)
    else
        set finalDate to startDate + (1000 * days)
    end if
else
    set finalDate to untl
end if
return finalDate
end getRecurrenceTermination

tell application "iCal"

set TheCalendars to name of calendars

set theSourceCalendar to ""
set theDestinationCalendar to ""

choose from list TheCalendars with title "Please select a source calendar" without empty selection allowed
set theSourceCalendar to result as string

if theSourceCalendar is "" then
    --do nothing
else

    set theOtherCals to {}
    repeat with anItem in TheCalendars
        if (anItem as string) is not (theSourceCalendar as string) then set theOtherCals to theOtherCals & anItem
    end repeat

    choose from list theOtherCals with title "Please select a destination calendar" without empty selection allowed
    set theDestinationCalendar to result as string


    if theDestinationCalendar is "" then
        --do nothing
    else

        display dialog "Copy calendar events from " & theSourceCalendar & " to " & theDestinationCalendar & "?" buttons {"OK", "Cancel"} default button 2
        if the button returned of the result is "OK" then
            set TheEvents to events of calendar theSourceCalendar
            set otherEvents to events of calendar theDestinationCalendar
            repeat with anEvent in TheEvents
                set curDate to current date
                set isNew to 1
                set startDate to start date of anEvent
                set endDate to end date of anEvent
                set eventStatus to status of anEvent
                set recuInfo to recurrence of anEvent
                set auid to uid of anEvent
                if recuInfo is not missing value then
                    set ed to my getRecurrenceTermination(startDate, recuInfo)
                end if
                if endDate ≥ curDate and eventStatus is not none then
                    --check that is not already existing using uid of events
                    repeat with oEvent in otherEvents
                        set ouid to uid of oEvent
                        if ouid is equal to auid then
                            set isNew to 0
                            exit repeat
                        end if
                    end repeat
                    if isNew is not 0 then
                        duplicate anEvent to end of calendar theDestinationCalendar
                    end if
                else
                    log "Event discarded: old"
                end if

            end repeat
        else
            --do nothing
        end if
    end if
end if
end tell

Credo che il flag di duplicazione dei problemi di controllo, quando non esistono duplicati, forse è dovuto a questo?

set auid to uid of anEvent
    
risposta data 18.03.2013 - 04:30
fonte

Leggi altre domande sui tag