Apple Script - Simple Navigation thru Preferences

Howdy,
I'm trying to us Apple Script to simply change my Network Location. I thought it would be easy, I must be missing something. Here is the code I've written so far that works...
tell application "System Preferences"
activate
set current pane to pane "Network"
end tell
Now, I want to change the Location field (I believe it's called an anchor) to my secondary (Home, for example). So, I added a line like such...
tell application "System Preferences"
activate
set current pane to pane "Network"
set anchor to "Location"
end tell
This 4th line doesn't work, but you get the idea. I have written many variations of this 4th line (i.e. 'set "Location" to "Home"'), nothing seems to work. And there doesn't seem to be much documentation on anchors (other than what's in the Dictionary).
Recording doesn't save it, so that's out of the question.
Does anyone have any ideas?? Thanks.
Bryan
iMac Intel   Mac OS X (10.4.7)  
iMac Intel   Mac OS X (10.4.7)  

Surround the line...
click button "Apply" of sheet 1
... with 'try ... end try', as shown below ...
try
click button "Apply" of sheet 1 -- Select the'Apply' button of drop down sheet.
end try
Full code, with comments:
property tMenu : "Home" -- The menu item to select.
tell application "System Preferences" -- Launch application
activate
set current pane to pane "com.apple.preference.network" -- Select 'Network' utility.
end tell
tell application "System Events" to tell process "System Preferences"
tell window 1
click pop up button 1 -- Select the 'Localtion' popup button.
click menu item tMenu of menu 1 of pop up button 1 -- Select the 'tMenu' menu item.
click button "Apply Now" -- Select the 'Apply Now' button.
click button 1 -- Select the Close button.
try
click button "Apply" of sheet 1 -- Select the'Apply' button of drop down sheet.
end try
end tell
end tell

Similar Messages

  • Automatic graphic switch via Apple Script

    hi community,
    I would like to change the "Automatic graphics switching" (tick on / tick off) via an Apple Script. I made the following script and it works, except with line "click chckbox 2". Here it ticks the box "Show battery status in menu bar". With "click checkbox 1" it takes the "Lock-Button".
    I would be glad if anybode could tell me the right code for ticking the checkbox "automatic graphics switching" via Apple Script.
    Thanks a lot
    PS: Yes I know that tool gfx Status, but I wanna do this via Apple Script.
    tell application "System Preferences"
      activate
              set current pane to pane "com.apple.preference.energysaver"
              delay 0.5
              tell application "System Events"
                        tell process "Systemeinstellungen"
                                  tell window "Energie sparen"
      click checkbox 2
                                            delay 0.5
                                  end tell
                        end tell
              end tell
      quit
    end tell
    quit

    Hello
    You may try this. It works with MacBook Pro 2010 under 10.6.5.
    tell application "System Preferences"
        set current pane to pane id "com.apple.preference.energysaver"
    end tell
    tell application "System Events"
        tell process "System Preferences"
            tell window 1
                tell group 1 -- automatic graphics switching
                    tell checkbox 1 -- automatic graphics switching
                        click
                    end tell
                end tell
            end tell
        end tell
    end tell
    And the script below will set the option to the specified value.
    set_automatic_graphics_switching(0)
    on set_automatic_graphics_switching(i)
            integer i : status of automatic graphics switching
                0 : off (unchecked)
                1 : on    (checked)
        if i is not in {0, 1} then error "Invalid argument: " & i number 8000
        tell application "System Preferences"
            set _was_running to running
            set current pane to pane id "com.apple.preference.energysaver"
        end tell
        tell application "System Events"
            tell process "System Preferences"
                tell window 1
                    tell group 1 -- automatic graphics switching
                        tell checkbox 1 -- automatic graphics switching
                            if value ≠ i then click
                        end tell
                    end tell
                end tell
            end tell
        end tell
        if not _was_running then
            tell application "System Preferences" to quit
        end if
    end set_automatic_graphics_switching
    Hope this may help,
    H

  • Open & close iTunes every night via Apple Script

    What I would like to do is have my Mac come out of sleep at 3am, open iTunes and download all my podcasts and then go back to sleep. Is this possible with Apple Script?

    In System Preferences>Energy Saver click on 'Schedule' and set 'Start Up or Wake' to 3 AM
    In iCal set up an event for 3.05, setting an alarm to Open File and selecting iTunes.
    Suppose you want to allow half an hour:
    In AppleScript Editor, write
    tell application iTunes to quit
    tell application "Finder" to sleep
    and save it somewhere as a script, not an application.
    Set up an event in iCal for 3.35 with an alarm, setting it to Run Script and selecting your script.

  • APPLE SCRIPT HELP! Simple Renaming Script

    I dont have any experience with apple script but desperately needed this for a work issue. I basically have tons of files with all the same type of name and need to send the first two numbers in the file to the end of the file as a suffix... so this...
    01 alexa_02.mp3
    needs to turn into this
    01 alexa_02_01.mp3
    So the function is take the first two characters from the file name of all the files in the folder and rename them with a suffix. Here is what I have so far.
    PLEASE HELP! Im desperate!
    [CODE]try
        tell application "Finder" to set the source_folder to (choose folder with prompt "Pick the folder containing the files to rename:") as alias
    end try
    display dialog "Change Suffix to First Two Characters of File Name:" buttons {"Send The Pids!", "Cancel"}
    set the button_pressed to the button returned of the result
    set the item_list to list folder source_folder without invisibles
    set source_folder to source_folder as string
    repeat with i from 1 to number of items in the item_list
        set this_item to item i of the item_list
        set this_item to (source_folder & this_item) as alias
        set this_info to info for this_item
        set the current_name to the name of this_info
        tell application "Finder"
            if the button_pressed is "Send The Pids!" then
                set the filename to the (current_name & the characters 1 thru 2 of current_name) as string
                set orig to quoted form of POSIX path of current_name
                set dest to source_folder & filename
                try
                    set y to dest as alias
                on error
                    set dest to quoted form of POSIX path of dest
                    set command to "mv " & orig & " " & dest
                    do shell script command
                end try
            end if
        end tell
    end repeat[/CODE]

    Made a short script on my own... normally you could do this using the Finder and run a recursive algorythm, but if you just use find to find all files in a folder that ft your criteria and use these links to generate a list of aliases (posix files) it is way faster and acomplished with less code :-)
    set myfolder to characters 1 through -2 of (POSIX path of ((choose folder) as alias)) as text
    set foundfiles to every paragraph of (do shell script "find " & quoted form of myfolder & " -type f -iname \"*.mp3\"")
    repeat with afile in foundfiles
    set afile to ((afile as text) as POSIX file as alias)
    tell application "Finder"
    set filename to name of afile
    set filesuffix to (characters -4 through -1 of filename) as text
    set addonsuffix to characters 1 through 2 of filename
    set filename to (characters 1 through -5 of filename) as text
    set newfilename to filename & "_" & addonsuffix & filesuffix
    set name of afile to newfilename
    end tell
    end repeat

  • Vocal command:how Apple script ?

    Hello, i'm new and i've got a question about Apple Script.
    I want to use the Vocal  Recognition for my app, is it possible?
    For example, i say to my computer "open safari and search to google "APPLE"" end the computer do that.
    I know that there is a similar program on the Preferences but i wan't to do another app to learn how to use the apple script.
    Thank you, bye!

    Try this
            -- Script Start
             set answer to text returned of (display dialog "Press the function key twice and talk" default answer "" buttons {"OK"} default button 1)
             if answer contains "open safari" and answer contains "google" then
                      set search to text ((offset of "google" in answer) + 6) thru -1 of answer
                      tell application "Safari"
                               open location "https://www.google.com/search?q=" & search & "&oq=" & search & "&aqs=chrome..69i57j0l5.1526j0j1&sourceid=chrome&espv=210&es_sm=91&ie=UTF-8/"
                      end tell
             end if
            -- Script End
    Hopt this helps

  • Its possible to convert Apple script to Java script

    Hi,
    Please Help me anyone to do that script.
    its possible to convert below mentioned Apple script to Java Script.
    Thanks in advance.
    Help me......!
    -yajiv
    Code:
    tell me to addImageLabels()
    on addImageLabels()
              tell application "Adobe InDesign CS5"
                        set numberAdded to 0
                activate
                        set enable redraw of script preferences to true
                        set currentFonts to (get name of every font)
                        if currentFonts does not contain fontname then
                                  display dialog "The font \"" & fontname & "\" is not active on your system." buttons {"Continue anyway", "Cancel"} default button 2
                        end if
                        tell document 1
      -- get a list of unique page IDs in this document
                                  set allpageids to my getPageIds()
                                  repeat with p from 1 to (length of allpageids)
                                            set pgid to item p of allpageids
      -- loop through these, getting a list of unique page item IDs to inspect
                                            tell page id pgid
                                                      set pageitems to (get id of every page item)
                                                      repeat with i from 1 to (length of pageitems)
                                                                set pid to item i of pageitems
                                                                tell page item id pid
                                                                          try
      -- certain boxes will fail to yield a content type, whatever
                                                                                    if content type is graphic type then
                                                                                              set c to class
                                                                                              set i to id
      -- get the name of the link, i.e. the filename, subject to labelFormat (full name, first six chars, etc.)
                                                                                              set gn to my getImageName(pgid, c, i)
                                                                                              if (gn is not "Empty") and (gn is not "") then
                                                                                                         set b to visible bounds
                                                                                                         set h to (item 3 of b) - (item 1 of b)
                                                                                                         set newtop to (item 1 of b) + (h / 2)
                                                                                                         set item 1 of b to newtop
                                                                                                         set w to (item 4 of b) - (item 2 of b)
                                                                                                         if w < minwidth then
                                                                                                                   set item 4 of b to ((item 4 of b) + 0.2)
                                                                                                                   set item 2 of b to ((item 2 of b) - 0.2)
                                                                                                         end if
                                                                                                         set l to (make new text frame at beginning of page id pgid with properties {visible bounds:b, fill color:fillcolor, contents:gn, label:"imagelabel"})
                                                                                                         tell l
                                                                                                                   tell paragraph 1
                                                                                                                             set justification to center align
                                                                                                                             try
                                                                                                                                       set applied font to fontname
                                                                                                                             end try
                                                                                                                             set point size to fontsize
                                                                                                                             set fill color to textcolor
                                                                                                                   end tell
                                                                                                                   set inset spacing of text frame preferences to ((insetspacing as string) & " in") as string
      fit given frame to content
                                                                                                                   set numberAdded to numberAdded + 1
                                                                                                         end tell
                                                                                              end if
                                                                                    end if
                                                                          end try
                                                                end tell
                                                      end repeat
                                            end tell
                                  end repeat -- allpageids
                        end tell -- document 1
      display dialog "Added " & numberAdded & " labels." buttons {okButton} default button 1 giving up after 10 with title scriptName
              end tell -- InDesign
    end addImageLabels
    on getPageIds()
              tell application "Adobe InDesign CS5"
                        tell document 1
                                  tell master spread 1
                                            set masterpageids to (get id of every page)
                                  end tell
                                  set docpageids to (get id of every page)
                        end tell
              end tell
              return masterpageids & docpageids
    end getPageIds
    on getImageName(int1, cla1, int2)
              tell application "Adobe InDesign CS5"
                        tell document 1
                                  tell page id int1
                                            if cla1 is rectangle then
                                                      set imagename to (name of item link of graphic 1 of rectangle id int2)
                                            else if cla1 is polygon then
                                                      set imagename to (name of item link of graphic 1 of polygon id int2)
                                            else
                                                      return "Unknown"
                                            end if
                                            try
                                                      if (labelformat is "First six characters") then
                                                                return (characters 1 thru 6 of imagename) as string
                                                      else if (labelformat is "Base name of linked file") then
                                                                set op to offset of "." in imagename
                                                                return (characters 1 thru (op - 1)) of imagename as string
                                                      else
                                                                return imagename
                                                      end if
                                            on error
                                                      return "Empty"
                                            end try
                                  end tell
                        end tell
              end tell
    end getImageName

    Yajiv:
    I realize English is probably not your first language, but you are not really making sense. Perhaps you could use more words and write in more detail.
    It seems you already have your script in AppleScript. Why do you need to convert it to JavaScript?
    It's going to be inconvenient at best and probably not worth anyone's time.
    Just use the AppleScript.

  • Automator workflow to an apple script

    Hello,
    i have a few problems with the automator utility:
    1. my automator work flow is to open an application and type a password.
    the problem is when i recored and i'm typing the password, after i'm running the workflow seems that its not possible to type password, is there a way to type password while recording?
    2. i have an automator workflow and i wish to convert it to an apple script.
    after i've copy paste it to the apple script editor it seems to be the workflow but when i running the
    script it not running.
    please help...
    Rafi.

    Since you're using Mail, you might be able to have Mail do it.
    You can set up a rule in Mail in its preferences to match an email with unique characteristics, such as certain content or a certain subject exactly. You might want to add a few conditions and "match all" to make sure you don't accidentally match something else.
    Anyways, you choose to have the rule run an AppleScript. I haven't tested it by referencing an Automator workflow, but it might work. You might try a quick test first with a simple workflow.
    You'd have to be logged in and have Mail automatically check for email, perhaps every minute or every five minutes. If you don't want to be logged in, likely you'll need to use a web page, like you suggested. I'm not sure what you need to do for that to work.

  • How to disable the option of "Overprint [Black] Swatch at 100%" in Indesign by Apple Scripting

    Hi Friends,
    I am new to Indesign Scripting by Apple Script. As a beginner, I am trying to do some basic scripting in Indesign by Apple Script.
    My aim is to disable the option of "Overprint [Black] Swatch at 100%" in Indesign. This option is available when we go to Indesign ---> Preferences----> Appearance of Black.
    Also, if a user opens a file, in which the swatch is already enabled, then it should prompt him for disabling.
    I can make a display dialog in AppleScript. But, I am bit unsure as how can I go ahead and disable this option. I tried this below script:
    tell application "Adobe InDesign CS4"
          tell every layout window to set overprint preview to false
    end tell
    However, it is changing the view option to overprint preview.
    Appreciate your help and suggestions!
    Thanks,
    Abhishek

    tell application "Adobe InDesign CS5"
              tell the active document
                        set overprint black of document preferences to false
              end tell
    end tell

  • Apple Script for indesign

    Hai all,
    i am trying to insert footnote and its contents for a particular xml element in "Adobe Indesign cs2" thru apple script. But i'm facing some problem. I'm able to select the xml element and its contents and i can insert footnote for that element and i can cut that contents but i couldn't paste this contents in footnote. I have tried with the following code:
    tell application "Adobe InDesign CS2"
    tell active document
    set theRoot to (item 1 of XML elements)
    end tell
    end tell
    myLoopLoop(theRoot)
    property myLoLoV : {}
    property myHoHoV : {}
    on myLoopLoop(myElement)
    tell application "Adobe InDesign CS2"
    tell active document
    set moreElement to every XML element of myElement
    repeat with x from 1 to (count of moreElement)
    set em1 to item x of moreElement
    select em1
    if (name of markup tag of em1 is "informalexample") then
    set em2 to em1
    select text of em2
    tell insertion point 1 of em1
    set myfootnote to make footnote
    end tell
    tell application "Adobe InDesign CS2"
    set myselection to selection
    cut (selection of active document)
    end tell
    tell application "Adobe InDesign CS2"
    tell insertion point 1 of myfootnote
    paste into myfootnote
    set text of em2 to myfootnote
    end tell
    end tell
    end if
    tell me to myLoopLoop(item x of moreElement)
    end repeat
    end tell
    end tell
    end myLoopLoop
    Can anyone help me out to sort this problem?
    Thanks
    anbu
    I Mac   Mac OS X (10.4.8)   Intel based Mac

    hi all
    any help
    thanks
    anbu

  • Using c++ variable in apple script

    Hi all,
    I am just calling the apple script from my indesign plugin.
    I need to pass the c++ variable to apple script for opening a file
    This in my apple Script which i have embedded in c++ code
    tell application "TextEdit"
    activate
    open "Users:User1:Library:Preferences:Adobe Indesign:Version 5.0:MathEQ.txt"
    end tell
    The filepath "Users:User1:Library:Preferences:Adobe Indesign:Version 5.0:MathEQ.txt" is stored in the C++ variable char* textFileName.
    I need to use the variable textFileName in apple script which has the path.
    How to go about it?
    Thanks
    Sakthi

    I have a similar problem trying to get data from any field into an AppleScript variable.
    Something like *set phoneNumber to cell "Phone Number" of current record* works fine if you are using the script from a layout that has this field on it.
    But I have a lot of fields on different layouts and I want to have access to all fields in the table, no matter what layout they are on, or what layout is currently active.
    And I want to do this without having to specify on what layout each field is located.
    In the past (FileMaker 6) I used something like *set phoneNumber to (cell "Phone Number" of current record of database 1)* but this is no longer working in FileMaker 9.
    So I was thinking to use something like *set phoneNumber to cell "Phone Number" of current record of table "Table Name"* but that doesn't seem to work.
    The only thing that seems to work is *set phoneNumber to cell "Phone Number" of current record of layout "Layout Name"* but as I said, I don't want to specify the layout for each field.
    Any ideas anyone?
    Message was edited by: khasmir

  • XML Comment in Indesign using Apple script.

    Hi all,
    How to find the selected XML element is commented in indesign and get XML comment value in thru apple script. Any Ideas?
    -Jacintha

    You can have as many comments as you want so they require you to state the index of the comment in your reference.
    Assuming you have an object reference for the XML element, you would replace "associated XML element of selection" with that.
    tell application "Adobe InDesign CS3"   
        set myComments to {}
        if every XML comment of associated XML element of selection is not {} then
            set end of myComments to value of every XML comment of associated XML element of selection
        end if
        return myComments
    end tell
    if you know there's only going to be one comment then,
    tell application "Adobe InDesign CS3"
        if every XML comment of associated XML element of selection is not {} then
            set  myComment to value of XML comment 1 of associated XML element of selection
        end if
        return myComment
    end tell
    ~Mike

  • Apple Script to Sort through the Address Book

    Dear All,
    I am quite new to Apple and just a learner on Apple-scripts. Its been quite a task to learn.. I would require some help on a few things..
    The script will eventually use numbers to send email and get the user inputs and any yet to reach there..
    After going through lots of scripts to sort through the address book and make a clean address book, i found they are quite slow in processing takes about 20~30 Minutes to get through 2000 Contacts..
    Hence after reading posting of Mr. Koenig & Mr. Hiroto and specifically on deep copy. I have written the following code which does the following on 2000 records within 6~8Mins.
    The Script work its way through all the contact is the address List.. and creates Groups
    1. Duplicate Email Id's — List of Contacts with same email ID's including Contacts where the email Id is entered twice.. (Strange.. Address Book Issue, copy of the email Id under work & home)
    2. Duplicate Phone — List of Contacts with same Phone Numbers including Contacts where the Phone Nos is entered twice.
    3. Duplicate Name — List of Contacts with Same Names
    4. Duplicate No Name — List of Contacts without the First Name and Last Name
    it also sort the Contacts under the following Group which you can edit later with all the information's..
    1. Only Email Ids — List of Contacts with Email ID and No Phone Numbers
    2. Only Phone — List of Contacts with Phone Numbers and No Email Id's
    3. No Email or Phone — List of Contacts with No Email Id's and No Phone numbers (some half completed contacts )
    My Question to the forum is why is the following code still taking too much time..
    set onlyDupEList to every person of group theGroupEmail
    repeat with j from 1 to count of Dup_email
    set tempdata to item j of Dup_email
    if onlyDupEList does not contain {tempdata} then add tempdata to group theGroupEmail
    end repeat
    save application "Address Book"
    and the scripts slows down when the items in the list is quite large (over 800 or so )..
    Any help is appreciated and thanks in advance..
    -- the code ---
    global MsgTitle
    on run
    set MsgTitle to "Search for Duplicates in Address Book Contacts"
    display dialog ¬
    "This Script takes a while to finish" & return & "maybe 10 min or More..." & return & "Depending on the Address Book Contacts." & return & return & "Hence Allow it to run for the while" with title MsgTitle ¬
    with icon 1 ¬
    buttons {"Continue"} ¬
    giving up after 5
    set question to display dialog "Select the Duplicate Search Parameter " with icon 1 with title MsgTitle ¬
    buttons {"Contact Name", "Contacts on Phone & Email Id's", "Quit"} default button 3
    set rtnValue to button returned of question
    if rtnValue is "Quit" then
    -- tell application "Address Book" to quit
    tell me to quit
    end if
    if rtnValue is "Contact Name" then
    -- tell application "Address Book" to quit
    GetDup_byName("Duplicate Name")
    end if
    if rtnValue is "Contacts on Phone & Email Id's" then --Contacts on Phone & Email Id's
    -- tell application "Address Book" to quit
    Get_dup()
    end if
    end run
    --- Search on Name Field ---
    on GetDup_byName(theGroupName)
    set question to display dialog "Do you want to search for duplicates based on Names? " with icon 0 with title MsgTitle ¬
    buttons {"Continue", "Quit"} default button 1
    set rtnValue to button returned of question
    if rtnValue is "Quit" then
    -- tell application "Address Book" to quit
    tell me to quit
    end if
    tell application "Address Book"
    activate
    set biglist to {}
    set NoNameList to {}
    set theGroupNoName to "Duplicates No Names"
    set theGroup to theGroupName
    -- if not (exists (group "Dupilicate Entries")) then
    if not (exists (group theGroup)) then
    make new group with properties {name:theGroup}
    save
    end if
    if not (exists (group theGroupNoName)) then
    make new group with properties {name:theGroupNoName}
    save
    end if
    set the_names to name of people
    repeat with i from 1 to number of items in the_names
    set theName to item i of the_names
    -- return theName
    if theName is not in biglist then
    copy theName to end of biglist
    else
    set counter to (people whose name is theName)
    if (count of counter) > 1 then
    repeat with i from 1 to number of items in counter
    set this_item to item i of counter
    -- display dialog this_item
    add this_item to group theGroup
    end repeat
    -- return counter as string
    end if
    end if
    -- captures the Contacts without Name ---
    if theName contains "@" then
    -- display dialog theName
    set counterList to (people whose name is theName)
    repeat with i from 1 to number of items in counterList
    set this_item to item i of counterList
    -- display dialog this_item
    add this_item to group theGroupNoName
    end repeat
    end if
    -- save application "Address Book"
    end repeat
    save application "Address Book"
    set peopleCount to (count every person)
    -- set peopleCount to 50 -- only for testing --
    repeat with i from 1 to peopleCount
    set first_name to first name of person i as string
    set Last_Name to last name of person i as string
    if first_name is equal to "missing value" and Last_Name is equal to "missing value" then
    -- display dialog first_name & " : " & Last_Name
    set end of NoNameList to (id of person i)
    end if
    end repeat
    repeat with j from 1 to the count of NoNameList
    set tempdata to item j of NoNameList
    -- set testdata to person id tempdata
    -- if (name of groups of testdata does not contain theGroupNoEmail) then
    add tempdata to group theGroupNoName
    -- end if
    end repeat
    save application "Address Book"*)
    display dialog ¬
    "This Script Finished Processing Address Book Contacts the Duplicates are in the group" with title MsgTitle ¬
    with icon 1 ¬
    buttons {"Continue"} ¬
    giving up after 5
    end tell
    end GetDup_byName
    on Get_dup()
    set question to display dialog "Do you want to search for duplicates based on Names? " with icon 0 with title MsgTitle ¬
    buttons {"Continue", "Quit"} default button 1
    set rtnValue to button returned of question
    if rtnValue is "Quit" then
    -- tell application "Address Book" to quit
    tell me to quit
    end if
    tell application "Address Book"
    activate
    set theGroupEmail to "Duplicate Email Id's"
    set theGroupPhone to "Duplicate Phone"
    set theGroupNoEmail to "Only Phone Numbers"
    set thegroupNoPhone to "Only Email Id's"
    set theGroupNoData to "No Email or Phone"
    -- set theGroup to theGroupName
    if not (exists (group theGroupEmail)) then
    make new group with properties {name:theGroupEmail}
    save "Address Book"
    end if
    if not (exists (group theGroupPhone)) then
    make new group with properties {name:theGroupPhone}
    save "Address Book"
    end if
    if not (exists (group theGroupNoEmail)) then
    make new group with properties {name:theGroupNoEmail}
    save "Address Book"
    end if
    if not (exists (group thegroupNoPhone)) then
    make new group with properties {name:thegroupNoPhone}
    save "Address Book"
    end if
    if not (exists (group theGroupNoData)) then
    make new group with properties {name:theGroupNoData}
    save "Address Book"
    end if
    set ListofPeople to people --the_ID
    set ListofEmailID to value of emails of people --the_emails
    -- return ListofEmailID
    set ListofPhones to value of phone of people -- the_phones
    -- return ListofPhones
    set biglist to {}
    set ListEmail_Uniq to {}
    set ListEmail_Dup to {}
    set No_PhoneList to {}
    set No_EmailList to {}
    set No_dataList to {}
    set FlagEmail to false
    set FlagPhone to false
    -- repeat with i from 1 to number of items in the_emails
    repeat with i from 1 to count of ListofEmailID
    set thePersonID to item i of ListofPeople
    set theEmails to item i of ListofEmailID
    if theEmails is equal to {} then
    set end of No_EmailList to thePersonID
    else
    -- set FlagEmail to true
    repeat with j from 1 to count of theEmails
    set tmpdata to item j of theEmails
    -- return tmpdata
    if tmpdata is not in biglist then
    set end of biglist to tmpdata
    set end of ListEmail_Uniq to {tmpdata} & {thePersonID}
    else
    set end of ListEmail_Dup to {tmpdata} & {thePersonID}
    end if
    end repeat
    end if
    end repeat
    -- return ListEmail_Uniq
    -- return ListEmail_Dup
    -- save application "Address Book"
    set biglist to {}
    set ListPhone_Uniq to {}
    set ListPhone_Dup to {}
    -- repeat with i from 1 to number of items in the_emails
    repeat with i from 1 to count of ListofPhones
    set thePersonID to item i of ListofPeople
    set thePhones to item i of ListofPhones
    if thePhones is equal to {} then
    set end of No_PhoneList to thePersonID
    else
    -- set FlagPhone to true
    repeat with j from 1 to count of thePhones
    set tmpdata to item j of thePhones
    -- return tmpdata
    if tmpdata is not in biglist then
    set end of biglist to tmpdata
    set end of ListPhone_Uniq to {tmpdata} & {thePersonID}
    else
    set end of ListPhone_Dup to {tmpdata} & {thePersonID}
    end if
    end repeat
    end if
    end repeat
    -- return ListPhone_Uniq
    -- return ListPhone_Dup
    set the Dup_email to {}
    -- Find the Duplicates from the sorted list --
    repeat with i from 1 to the count of ListEmail_Dup
    set tempdata to item i of ListEmail_Dup
    set dataEmailDup to item 1 of tempdata
    set dataPersonDup to item 2 of tempdata
    repeat with j from 1 to the count of ListEmail_Uniq
    set tempdata to item j of ListEmail_Uniq
    set dataEmailUniq to item 1 of tempdata
    set dataPersonUniq to item 2 of tempdata
    -- display dialog mainEmail1 & "=" & mainEmail2 & " " & mainID1 & "=" & mainID2
    if dataEmailDup is equal to dataEmailUniq then
    set end of Dup_email to dataPersonDup -- & "," & dataPersonUniq
    set end of Dup_email to dataPersonUniq
    end if
    (* -- the code takes lot more time if add to group was used --
    if dataEmailDup is equal to dataEmailUniq then
    set testdata to person id dataPersonDup
    add testdata to group theGroup
    set testdata to person id dataPersonUniq
    add testdata to group theGroup
    end if
    end repeat
    end repeat
    -- return Dup_email
    set the Dup_Phone to {}
    -- Find the Duplicates from the sorted list --
    repeat with i from 1 to the count of ListPhone_Dup
    set tempdata to item i of ListPhone_Dup
    set dataPhoneDup to item 1 of tempdata
    set dataPersonDup to item 2 of tempdata
    repeat with j from 1 to the count of ListPhone_Uniq
    set tempdata to item j of ListPhone_Uniq
    set dataPhoneUniq to item 1 of tempdata
    set dataPersonUniq to item 2 of tempdata
    -- display dialog mainEmail1 & "=" & mainEmail2 & " " & mainID1 & "=" & mainID2
    if dataPhoneDup is equal to dataPhoneUniq then
    set end of Dup_Phone to dataPersonDup -- & "," & dataPersonUniq
    set end of Dup_Phone to dataPersonUniq
    end if
    (*if dataPhoneDup is equal to dataPhoneUniq then
    set testdata to person id dataPersonDup
    add testdata to group theGroup
    set testdata to person id dataPersonUniq
    add testdata to group theGroup
    -- save
    end if*)
    end repeat
    end repeat
    -- return Dup_Phone
    set onlyDupEList to every person of group theGroupEmail
    repeat with j from 1 to count of Dup_email
    set tempdata to item j of Dup_email
    if onlyDupEList does not contain {tempdata} then add tempdata to group theGroupEmail
    end repeat
    save application "Address Book"
    set onlyDupPList to every person of group theGroupPhone
    repeat with j from 1 to count of Dup_Phone
    set tempdata to item j of Dup_Phone
    if onlyDupPList does not contain {tempdata} then add tempdata to group theGroupPhone
    end repeat
    save application "Address Book"
    set onlyPhoneList to every person of group theGroupNoEmail
    repeat with j from 1 to the count of No_EmailList
    set tempdata1 to item j of No_EmailList
    if No_PhoneList does not contain {tempdata1} then
    if onlyPhoneList does not contain {tempdata1} then add tempdata1 to group theGroupNoEmail
    end if
    (*set flagE to false
    repeat with i from 1 to the count of No_PhoneList
    set tempdata2 to item i of No_PhoneList
    if tempdata1 is equal to tempdata2 then
    set flagE to true
    exit repeat
    end if
    end repeat
    if flagE is false then add tempdata1 to group theGroupNoEmail*)
    end repeat
    save application "Address Book"
    set onlyEmailList to every person of group thegroupNoPhone
    repeat with j from 1 to the count of No_PhoneList
    set tempdata1 to item j of No_PhoneList
    if No_EmailList does not contain {tempdata1} then
    if onlyEmailList does not contain {tempdata1} then add tempdata1 to group thegroupNoPhone
    end if
    end repeat
    save application "Address Book"
    set onlyList to every person of group theGroupNoData
    repeat with i from 1 to count of ListofPeople
    if (item i of ListofEmailID is equal to {}) and (item i of ListofPhones is equal to {}) then
    set tempdata to item i of ListofPeople
    if onlyList does not contain {tempdata} then add tempdata to group theGroupNoData
    end if
    end repeat
    save application "Address Book"
    display dialog ¬
    "This Script Finished Processing Address Book Contacts the Duplicates are in the group" with title MsgTitle ¬
    with icon 1 ¬
    buttons {"Continue"} ¬
    giving up after 5
    end tell
    end Get_dup
    on quit
    --set MsgTitle to "Change Email ID's Domain Name"
    save application "Address Book"
    display dialog "Contact Srikanth Kamath at [email protected] for any Help" with title MsgTitle with icon 1 buttons "OK"
    continue quit
    end quit

    Hello Srikanth Kamath,
    I'm not sure you're still following this thread, but anyway here's sample code I said I'd post later.
    --SCRIPT2
    main()
    on main()
    script o
    -- input data
    property xx : {1, 2, 3, 4, 5} -- list of parents
    property yy : {{"g", "h"}, {"a", "b"}, {"b", "e", "f"}, {"e"}, {"c", "d"}} -- list of children per parent
    -- work list
    property pp : {} -- list of children tagged by parent; i.e, lits of {child, parent}
    property qq : {}
    property rr : {}
    -- (1) build list of children tagged by parent
    repeat with i from 1 to count my xx
    set x to my xx's item i
    set y to my yy's item i
    repeat with p in y
    set end of my pp to {p's contents, x}
    end repeat
    end repeat
    --return pp -- {{"g", 1}, {"h", 1}, {"a", 2}, {"b", 2}, {"b", 3}, {"e", 3}, {"f", 3}, {"e", 4}, {"c", 5}, {"d", 5}}
    -- (2) sort tagged list by child as key
    msort(my by_key1, my pp)
    --return pp -- {{"a", 2}, {"b", 2}, {"b", 3}, {"c", 5}, {"d", 5}, {"e", 3}, {"e", 4}, {"f", 3}, {"g", 1}, {"h", 1}}
    -- (3) retrieve parents with duplicate child
    (* retrieve list of {child, parent} for duplicate child *)
    set my qq to uniq(my eq_key1, my pp, {_dup:true})
    --return qq -- {{"b", 2}, {"b", 3}, {"e", 3}, {"e", 4}}
    (* retrieve list of parent *)
    repeat with q in my qq
    set r to q's item 2
    if r is not in my rr then set end of my rr to r
    end repeat
    return rr -- {2, 3, 4}
    end script
    tell o to run
    end main
    on by_key1(x, y)
    msort's comparator for list of lists
    key = item 1, ascending
    returns true iff x and y are out of order
    return x's item 1 > y's item 1
    end by_key1
    on eq_key1(x, y)
    uniq's comparator for list of lists
    key = item 1
    returns true iff x and y are considered equal
    return x's item 1 = y's item 1
    end eq_key1
    on msort(cmp_, aa) -- v1.2f2
    Basic recursive merge sort handler having list sorted in place.
    handler cmp_ : comparator
    * cmp_(x, y) must return true iff list element x and y are out of order.
    list aa : list to be sorted in place
    script o
    property parent : {} -- limit closure to minimum
    property xx : aa -- to be sorted in place
    property xxl : count my xx
    property yy : {}
    property cmp : cmp_
    on merge(p, q, r)
    property xx: source list
    integer p, q, r : absolute indices to specify range to be merged such that
    xx's items p thru r is the target range,
    xx's items p thru (q-1) is the first sublist,
    xx's items q thru r is the second sublist.
    (p < q <= r)
    local i, j, k, xp, xr, yi, yj, ix, jx
    if r - p = 1 then
    set xp to my xx's item p
    set xr to my xx's item r
    if my cmp(xp, xr) then
    set my xx's item p to xr
    set my xx's item r to xp
    end if
    return -- exit
    else
    if p < q - 1 then merge(p, (p + q) div 2, q - 1)
    merge(q, (q + r + 1) div 2, r)
    end if
    At this point, sublits xx[p, q-1] and xx[q, r] have been already sorted (p < q <= r)
    if my cmp(my xx's item (q - 1), my xx's item q) then
    else -- xx[p, q-1] & xx[q, r] are already sorted
    return
    end if
    set yy to my xx's items p thru r -- working copy for comparison
    set ix to q - p
    set jx to r - p + 1
    set i to 1
    set j to q - p + 1
    set k to p
    set yi to my yy's item i
    set yj to my yy's item j
    repeat
    if my cmp(yi, yj) then
    set my xx's item k to yj
    set j to j + 1
    set k to k + 1
    if j > jx then
    set my xx's item k to yi
    set i to i + 1
    set k to k + 1
    repeat until k > r
    set my xx's item k to my yy's item i
    set i to i + 1
    set k to k + 1
    end repeat
    return
    end if
    set yj to my yy's item j
    else
    set my xx's item k to yi
    set i to i + 1
    set k to k + 1
    if i > ix then
    set my xx's item k to yj
    set j to j + 1
    set k to k + 1
    repeat until k > r
    set my xx's item k to my yy's item j
    set j to j + 1
    set k to k + 1
    end repeat
    return
    end if
    set yi to my yy's item i
    end if
    end repeat
    end merge
    on cmp(x, y)
    (* primary comparator *)
    return x > y
    end cmp
    local d, i, j
    if xxl ≤ 1 then return
    if cmp_ = {} then set my cmp to cmp -- comparator fallback
    my merge(1, (xxl + 1) div 2, xxl)
    end script
    tell o to run
    end msort
    on uniq(eq_, aa, {dup:dup}) -- v0.21
    handler eq_ : comparator eq_(x, y) that returns true iff x and y are considered equal
    list aa : pre-sorted list
    (precisely, a list organized such that any duplicate items are adjacent to each other)
    boolean _dup : option whether return unique items or duplicate items
    return duplicate if true, unique otherwise.
    script o
    property parent : {} -- limit closure to minimum
    property xx : aa
    property yy : {}
    property eq : eq_
    on eq(x, y)
    (* primitive comparator *)
    x = y
    end eq
    if eq_ = {} then set my eq to my eq -- comparator fallback
    local t, x, _on
    if (count my xx) < 2 then return my xx's contents
    if _dup then
    set _on to false
    set t to my xx's item 1
    repeat with i from 2 to count my xx
    set x to my xx's item i
    if eq(x, t) then
    set end of my yy to t
    set _on to true
    else if _on then
    set end of my yy to t
    set _on to false
    end if
    set t to x
    end repeat
    if _on then set end of my yy to x
    return my yy's contents -- return duplicate elements
    else
    set t to my xx's item 1
    set end of my yy to t
    repeat with i from 2 to count my xx
    set x to my xx's item i
    if eq(x, t) then
    else
    set end of my yy to x
    set t to x
    end if
    end repeat
    return my yy's contents -- return uinque elements
    end if
    end script
    tell o to run
    end uniq
    --END OF SCRIPT2
    In order to apply it to your current Address Book problem, replace the main() handler with something like the following one.
    --SCRIPT2a (part)
    on main()
    script o
    -- input data
    property xx : {} -- list of parent; given later
    property yy : {} -- list of children per parent; given later
    -- work list
    property pp : {} -- list of children tagged by parent; i.e, lits of {child, parent}
    property qq : {}
    property rr : {}
    -- (0) get input data from AB
    tell application "Address Book"
    tell people
    set xx to its id
    set yy to its every email's value
    end tell
    end tell
    -- (1) build list of children tagged by parent *)
    (* omitted (same as the previous) *)
    -- (2) sort tagged list by child as key
    (* omitted (same as the previous) *)
    -- (3) retrieve parents with duplicate child
    (* omitted (same as the previous) *)
    -- (4) group the retrieved people in AB
    tell application "Address Book"
    repeat with r in my rr
    add person id r to group "duplicate email"
    end repeat
    end tell
    end script
    tell o to run
    end main
    --END OF SCRIPT2a
    Good luck,
    Hiroto
    Message was edited by: Hiroto

  • Apple script to batch rename files by deleting tags on front and back of the file name

    Hi, I'm trying to rename a couple thousand files from their current format:  "01074_Something Of A Dreamer_Mary-Chapin Carpenter.lrc"
                                                                                                                           "01075_Where Did We Go Right_Lacy J. Dalton.lrc"
                                                                                                                           "01076_Everybody's Reaching Out_Crystal Gayle.lrc"
                                                                                                         To simply:  "Something Of A Dreamer.lrc"
                                                                                                                           "Where Did We Go Right.lrc"
                                                                                                                           "Everybody's Reaching Out.lrc"
    I just want to delete the number tag on the front and the artist name at the end for all of the files.  I imagine a Script to do this wouldn't be too hard to write, something along the lines of read file name after the first '_' character it reads until it reads a second '_' character and rename the file to the string it reads between those two underscores with .lrc at the end.
    Unfortunately I know nothing about Apple Script other than it seems like the thing I would need to automate this process based on my limited google searches.  If someone could help me out with some advice on how to go about making this script or obviously if you simply have and/or can quickly write a script to do this it would be greatly appreciated!

    Here:
    tell application "Finder"
    repeat with this_file in (get files of window 1)
    set the_name to name of this_file
    set temp_name to items ((offset of "_" in the_name) + 1) thru -1 of the_name as string
    set temp_name to (items 1 thru ((offset of "_" in temp_name) - 1) of temp_name as string) & items -4 thru -1 of the_name as string
    set name of this_file to temp_name
    end repeat
    end tell
    (123647)

  • Script to change Safari Preferences

    Hello,
    I'm trying to build a script to change Safari Preferences :
    "Tell Application Safari"
    Set the default browser as "Safari"
    End Tell
    But it does not work...
    I will need it to make this change on a lot of Macs from Apple Remote Desktop.
    Do you know where are located the Apple Script Commands in Safari ?
    Thank you
    Marc

    Hi krsmes
    Try this GUI script, make sure enable for assisted devices is on in all your macs.
    activate application "Safari"
    tell application "System Events"
    tell process "Safari"
    click menu item "Preferences…" of menu 1 of menu bar item "Safari" of menu bar 1
    click button "General" of tool bar 1 of window 1
    tell pop up button 2 of group 1 of group 1 of window "General"
    click
    click menu item 6 of menu 1 -- change the number 6 to what ever number controls safari as default browser for you
    delay 1
    --tell application "System Events"
    --if (name of processes) contains "Safari" then tell application "Safari" to quit
    --end tell
    --or
    tell application "System Events"
    if (name of processes) contains "Safari" then tell application "Safari" to close window "General"
    end tell
    end tell
    end tell
    end tell
    Budgie
    Message was edited by: Budgie
    tested on G5PPC 10.4.11

  • Get AD group membership for apple script

    Hello All,
    I am to create an app that mounts certain network folders with an apple script:
    tell application "Finder" to close every window
    tell application "Finder" to eject (every disk whose local volume is false)
    tell application "Finder"
      tell Finder preferences
      set desktop shows connected servers to true
      set desktop shows external hard disks to true
      end tell
    end tell
    do shell script "killall Finder"
    display dialog "Please enter your network username:" default answer "" with title "Network Login" with icon note
    set username to text returned of result
    display dialog "Please enter your network password:" default answer "" with title "Network Login" with icon note with hidden answer
    set userpass to text returned of result
    mount volume "smb://" & username & ":" & userpass & "@192.168.1.10/teacherread"
    mount volume "smb://" & username & ":" & userpass & "@192.168.1.10/teacherwrite"
    mount volume "smb://" & username & ":" & userpass & "@192.168.1.10/home/" & username
    mount volume "smb://" & username & ":" & userpass & "@192.168.1.10/steps"
    The users are in Active Directory and are in certain groups
    I would like to go one step further and add: if in group teachers, and officestaff: mount teacherread, finance etc
    The macs are not bound to the domain
    Thanks in advance for your help
    Daniel

    Hi Again,
    Another way to look at it might be if error 5014 (don't have permission) try next line
    try
    mount volume "smb://" & username & ":" & userpass & "@dc1/teacherread"
    *if result is error number 5014 goto next command
    end try
    *try
    mount volume "smb://" & username & ":" & userpass & "@dc1/teacherwrite"
    *if result is error number 5014
    end try
    *try
    mount volume "smb://" & username & ":" & userpass & "@dc1/home/" & username
    *if result is error number 5014
    *end try
    *Not sure on syntax
    Thanks
    Daniel

Maybe you are looking for

  • Where can I get new charger for Satellite Pro L500-1D4?

    Hi, I would like to get a new charger for Toshiba. My first charger got lost and the second charger that I bought from ebay 3 months ago for 10,- has stopped working. Where can I get a charger from? I googled and I found couple of wesbites e.g. http:

  • Templates + Pop Up Menus

    I know, I know Murray, you said these don't work in the past, however, I made a template with a pop up / drop down (however you like to call it) menu and so far it seems to work just fine. Am I delusional ? Headed for a huge fall later on when I disc

  • I Need Help ID-ing My Stolen Macbook Pro

    Hello, my MacBook Pro 13" was stolen, it has Euro Keyboard Layout, Thats not common in Jamaica. Yesterday i saw a MacBook Pro at a Pawn Shop Fitting The Description of mine. How can i know for sure that its mine? i don't have the receipt, i dont know

  • Anyway to save slideshow as an exe file

    Hi Are there any slideshow programs for the Mac that save them as exe file? I want to play it on a  projector running on a PC Richard

  • How do i place a jpg image from scanner into InDesign without it getting pixelated?

    Hello, I am currently working on my internship portfolio. So far so good but in the end on one of the last pages I wanted to attach the recommendations I got from teachers. 2 of them I received in .pdf and simply imported they look like from the pdf.