1 votos

AppleScript para comparar los contactos de dos grupos y eliminar los duplicados de uno de ellos

Quiero crear un AppleScript para la aplicación Agenda (Contactos) de Apple que mire dos Grupos, y si un contacto está en un Grupo, lo elimine del otro Grupo.

En concreto, añado clientes potenciales a mi agenda para poder codificar por colores sus mensajes en Mail.app. Los añado a un grupo de "Trabajo - Pendiente". Una vez que el proyecto avanza, los añado a un grupo "Trabajo - Actual". El AppleScript compararía los dos, buscaría duplicados y los eliminaría del grupo "Pendiente".

3voto

Malik hassan Puntos 16

Aquí hay un script escrito rápidamente. Debería funcionar. Pero no lo he revisado para que sea eficiente.

tell application "Contacts"

    (*get the names of all groups *)
    set theGroupNames to name of groups

    (*choose you current group, the one to keep entries*)
    set text_returnedCurrent to choose from list theGroupNames with prompt "Choose Current Group" default items "Work - Current" without multiple selections allowed

    (*choose you pending group, the one to remove entries*)
    set text_returnedPending to choose from list theGroupNames with prompt "Choose Pending Group" default items "Work - Pending" without multiple selections allowed
    (*Get the people/entries of the Current group*)
    set the_peopleCurrent to people of group (text_returnedCurrent as text)

    (*Get the people/entries of the Pending group*)
    set the_peoplePending to people of group (text_returnedPending as text)

    (*iterate through the people of the Current group*)
    repeat with i from 1 to number of items in the_peopleCurrent

        (*get a person from the  Current group*)
        set thisPersonCurrent to item i of the_peopleCurrent

        (*iterate through ALL the people of the Pending group**)
        repeat with x from 1 to number of items in the_peoplePending

            (*get a person from the  Pending group*)
            set thisPersonPending to item x of the_peoplePending

            (*Check if the person from the Current group is the same person as thisPersonPending*)
            if thisPersonCurrent is equal to thisPersonPending then
                (* if they are remove them.  *)
                remove thisPersonPending from group (text_returnedPending as text)

                (*save the contacts changes*)
                save

            end if
        end repeat

    end repeat

end tell

0 votos

Eso ha servido, ¡muchas gracias! Voy a ver si puedo reducirlo para los dos grupos específicos con los que necesito hacer esto. Pero esto funciona exactamente como lo necesitaba.

0 votos

De nada. La reducción debería ser fácil de hacer. Lo hice de esta manera para que sea utilizable para otros.

AppleAyuda.com

AppleAyuda es una comunidad de usuarios de los productos de Apple en la que puedes resolver tus problemas y dudas.
Puedes consultar las preguntas de otros usuarios, hacer tus propias preguntas o resolver las de los demás.

Powered by:

X