Scheduling an Apple Script [eyeTV DVB Update] more...

Like many other eyeTV Users, I have opted out of the iceTV [Australia] annual subscription, and am using the DVB Program Guide.
But eyeTV does not support scheduled updates of the DVB Guide, only subscription services [annoying].
Recently ctzsnooze proposed an Apple Script which if run periodically would update of the eyeTV DVB Program Guide.
https://discussions.apple.com/thread/6043805
And a few years ago Camelot proposed a means to schedule a script to run periodically.
https://discussions.apple.com/thread/673340
After a little testing, I believe I have refined this script to properly run to a regular schedule.
Here is a copy of my updated version of Camelot's test routine: Note the following...
a) the initial date must be set in the future, otherwise the idle loop will run every five seconds [idle return is negative].
b) use >=, not simply > in the idle loop, otherwise the scheduled run time becomes offset [+5 * minutes in this example].
c) I found the display notification a really neat way to log progress of the script while testing, and have now incorporated a Notification into my file Script for the eyeTV Program Schedule Update, to confirm it has run once a day, or hour.
d) Compile then Save As, Application, and Stay open after run handler.  The first time you run it, you will need to authorise it...
property runTime : missing value
on run
          set runTime to date "Wednesday, 07 May 2014 13:45:00"
          display notification "Update Script initialised at: " & runTime
          display notification "Time now is: " & (current date)
end run
on idle
          if (get current date) ≥ runTime then
                    display notification "Update Script ran at: " & (current date)
                    set runTime to runTime + 5 * minutes
                    display notification "Next execution of Update Script will be at: " & runTime
          end if
          display notification "Script Return Value is: " & (runTime - (get current date))
          return (runTime - (get current date))
end idle
Here is an example run...
And here is my update to Ctzsnooxe's version of the eyeTV DVB Program Guide auto update script, and a copy of the resulting Notifications...
Delete the display notifications you do not wish to see from the script, once you prove the script.
property runTime : missing value
on run
          set runTime to date "Wednesday, 07 May 2014 15:00:00"
          display notification "eyeTV Programs Update Script initialised at: " & runTime
  display notification "Time now is: " & (current date)
end run
on idle
          if (get current date) ≥ runTime then
    display notification "eyeTV Programs Updated at: " & runTime
    tell application "EyeTV"
        activate
    end tell
    tell application "System Events"
      tell process "EyeTV"
        keystroke "g" using command down
        delay 1
        click (pop up button 1 of window 1)
        delay 1
        click menu item "Update DVB Program Guide" of menu 1 of pop up button 1 of window "EyeTV Programs"
      end tell
    end tell
    set runTime to runTime + 1 * days
    display notification "Next Update of eyeTV Programs will be at: " & runTime
          end if
          display notification "Script Return Value is: " & (runTime - (get current date))
          return (runTime - (get current date))
end idle

Stephen,
I ran into some scheduling issues after Wake from Sleep, and after some fiddling around, made the following changes.
This version is set up to run every hour [so I could test error handling, window, wake, and sleep issues]
-- eyeTVAutoUpdate (Hour) Script:
-- [for testing, setup to run every hour...]
-- When proper operation is confirmed,
--       Set Systems Preferences, Energy Saver, Schedule, Startup or Wake, to
--       Every Day, at 15:45hr, and
--       Set eyeTV Programs Update Script to run at 16:00hr every day
property runTime : missing value
on run
   set runTime to (get current date)
   set (time of runTime) to 10 * hours
  repeat while runTime < (get current date)
     set runTime to runTime + 1 * hours
  end repeat
  display notification "eyeTVAutoUpdate Script initialised: " & return & (current date)
end run
on idle
   try
   tell application "EyeTV"
      activate
      close controller window
   end tell
   tell application "System Events"
      tell process "EyeTV"
         keystroke "g" using command down
         delay 1
         click (pop up button 1 of window 1)
         delay 1
         click menu item "Go to Now" of menu 1 of pop up button 1 of window "EyeTV Programs"
         delay 1
         click (pop up button 1 of window 1)
         delay 1
         click menu item "Update DVB Program Guide" of menu 1 of pop up button 1 of window "EyeTV Programs"
      end tell
   end tell
   display notification "eyeTV Programs Updated: " & return & (current date)
on error errorMessage number errorNumber
   display notification ("An error occurred: " & errorNumber as text) & return & "Description: " & errorMessage as text
end try
repeat while runTime < (get current date)
   set runTime to runTime + 1 * hours
end repeat
display notification "Next Update of eyeTV Programs: " & return & runTime
display notification "eyeTVAutoUpdate Script Return: " & (runTime - (get current date))
return (runTime - (get current date))
end idle
Although I have not yet tested it, simply change the last repeat while loop time interval [now one hour] to suit, say to 8 or 24 hours.
For example...
repeat while runTime < (get current date)
   set runTime to runTime + 8 * hours
end repeat
  repe

Similar Messages

  • Email Scheduler Now Works! (Apple Script!)

    Hey everyone,
    For all wondering how to schedule emails ahead of time to go out, the programmer has updated the "Schedule Delivery" Apple Script and it now works. I tried this 2 years ago and it was a pain after 10.5 as it was very buggy. But now it's up and running!
    Mail Scripts - 2.9.1
    Workflow-enhancing AppleScripts for Mail & Address Book
    http://www.versiontracker.com/dyn/moreinfo/macosx/16217

    thanks a lot for the info. this ability is often requested. MailScripts was the only tool to offer it but it didn't work in leopard. of course, Apple really ought to have this functionality built in...

  • Apple Script to Check for System as well as Applications Updates?

    Hi,
    I was wondering if someone has created an Apple Script to check for Finder as well as Applications updates automatically.
    Thanks,
    Nawaf
    MacBook 13" 2Ghz 2GB   Mac OS X (10.4.7)  

    There wouldn't be any updates to the Finder separately. Any system updates are announced by Apple when they're available, and this is what the Software Update feature is for.
    If you go to System Preferences->Software Update, you can set it to automatically check for updates, or you can check manually. Monthly is usually the best schedule to check for updates, as Apple doesn't often release things on any quicker schedule.
    Mulder
    If this answered you question, please consider awarding some points. Why Reward Points?
    iMac G4 700Mhz   Mac OS X (10.3.9)  

  • TS3694 iOS 7.02 update made my iPad stay frozen on the appl logo.  What's more, a factory update in DFU mode won't work either, I get error code 3194 - any tips on what I should do?  It is an iPad2 on iOS 5 something, the one just before Apple removed You

    iOS 7.02 update made my iPad stay frozen on the appl logo.  What's more, a factory update in DFU mode won't work either, I get error code 3194 - any tips on what I should do?  It is an iPad2 on iOS 5 something, the one just before Apple removed YouTube...

    iOS 7.02 update made my iPad stay frozen on the appl logo.  What's more, a factory update in DFU mode won't work either, I get error code 3194 - any tips on what I should do?  It is an iPad2 on iOS 5 something, the one just before Apple removed YouTube...

  • Apple every day is looking more alike Microsoft leaving the loyal costumers hanging by not updating EFI so 2006 inte macpro can run mountain Lion

    Apple every day is looking more alike Microsoft leaving the loyal costumers hanging by not updating EFI so 2006 inte macpro can run mountain Lion

    Greetings,
    The EFI is not why a 2006 MACPro cannot run ML, the thing is almost an antique, when you consider how fast things move in the tech world.
    No one says that you have to update to ML - I still have a G4 running plain old Leopard, and it works for me for what I need it for. I have several Macs (7) of all ages, and only three of them can run ML, but only two of them ever will, until I buy a new one.
    If ML is that important to you, then it's time to upgrade - normal upgrade paths for over 90% of us is three, to four years, max, to keep up with the latest and greatest. Its Ok to keep th eolder machines for th eusual run of the mill activities, like email, surfing the web, playing music, the odd video, etc.
    Cheers,
    M.

  • More Apple Gobbledegook.  Cannot update my phone as message comes through "updating to iOS 7.0.4 requires at least 610 MB of free space on your iPhone.  Please change your media sync options to make more storage available"  What media sync options?  Where

    More Apple Gobbledegook.
    Cannot update my phone as message comes through "updating to iOS 7.0.4 requires at least 610 MB of free space on your iPhone.  Please change your media sync options to make more storage available"
    What media sync options?  Where are they ? How do I change them?

    Afraid, this doesnt help.  I've already unselected about 100 iTunes, resynced, and I still get the same message about 610 MB needing to be deleted.
    What is so magic about 610 MB as a number?
    Is this anything to do with iCloud? I was on the free 20 MB offeruntil last month and then got downgraded to 5 because I could n't see the need for paying for extra Cloud space.   Is this the reason why?

  • Scheduling an sql script using dbms_scheduler

    Hi Experts,
    I am having an oracle 10g database on windows platform. I have an sql script which has a normal set of sql statements (insertion and updation).
    I would like to schedule to run this sql script using dbms_scheduler but I've gone through certain sites and came to know that it's not possible to schedule an sql script using dbms_scheduler. Please let me know how I can schedule this script using dbms_scheduler.

    It is possible - in 10g and above you can use DBMS_SCHEDULER to call an external procedure, which in this case could be a call to your SQL file.
    Get's a bit more complicated with older versions, but still doable.
    But - unless there is a really good reason why you cannot do so, move this into a PL/SQL procedure as suggested.
    Carl

  • Looking a Apple Script please Help !

    I am looking for a Apple script which I start the Mac App Store and dirket jump to the updates. Is that possible?  If so  can i combine that  with the Automator on Mac ?

    Can you post more information?
    What happens when you type "python script.py"?  Do you get some sort of error message?
    If you type only the name of the script then you will have to make sure you have changed directory to where the script is located first. For example if your script is saved to your desktop, when you start Terminal you will first need to do "cd ~/Desktop" to change directory.
    Or alternatively you could type the path to the script:   python ~/Desktop/script.py
    Steve

  • Writing apple script to perform actions on specific network shares/servers

    Hi Everyone,
    I'm new to posting to this forum, but had a few simple questions about writing Apple Script. I've created a few network shares on our home network, and wrote an apple script to automatically mount the shares upon login. However, there's 2 things I'm missing:
    1. how to add a password feild to the script, along with the username.
    2. how to make the resulting application from the script (or the script itself) ignore the errors that result when i am not at home, and the server is not available (basically I'm saying I don't want to see those errors pop up)
    3. I also don't want to see the error from the network agent, about the server being unavailable.
    Any help with this would be greatly appreciated. Here is my script so far:
    tell application "Finder"
              mount volume "smb://mediaserver/automatically add to iTunes/" as user name "Rocco Fiorentino"
              mount volume "smb://mediaserver/shared media" as user name "Rocco Fiorentino"
    end tell
    Thank you in advance for any assistance. Have a great day!

    John Holley NZ wrote:
    More importantly I have found that the names in the list don't match the descriptions!
    Let's take one update for example, 061-3405 Pro Application Update 2007-01.
    Although this completely defies logical explanation, If you resist sorting the list by anything (i.e. the default random order), the descriptions will in fact be correct. This is something I see from time to time with new Excel users when they try to sort related columns for the first time and forget to select all of the relevant data, but I am totally perplexed as to why this is happening here. It seems as though the descriptions are not actually part of the file, and as such, cannot be sorted (or don't follow around the original file).
    For example, on my server, QuickTime Broadcaster 1.5 is followed by Logic Express 7.2.1. If I sort by name, the list starts with an Airport updater, but the first 2 descriptions remain the SAME (QT and Logic)! As I previously stated: this defies all logic and reason.
    For me, this seems to be a cosmetic problem; the software update server is successfully serving updates to clients. It is, however, annoying.
    Something seems seriously screwed here! I will keep digging but this does not fill me with confidence.
    John

  • HELP : APPLE SCRIPT ISSUES!

    I am trying to make an apple script that will detect when an application (minecraft,cod or other online downloaded software/games) is open and then bring up a dialog that wont go away so that only I.T. can remove it. I also want it to send an email to a certain adress saying that so and so has been playing games
    It's a school project that im working on, we have to figure out a way (through applescript) to help students be more productive, everyone else has no experience with apple script but me. I managed to create this in a couple of minutes but there is a couple glitches and problems i cant solve.
    the problems include
    it doesn't work with non-appstore apps ie. apps downloaded for the internet
    i want it to be able to detect numerous programs
    it doesn't close the program and/or bring the window/dialog to the top.
    I have used safari as an example as to where a list of "illeagle apps" should be.
    here's the script:
    tell (get system info)
              set longName to long user name
              set shortName to short user name
    end tell
    if appIsRunning("Safari") then
              tell application "Mail"
                        set theNewMessage to make new outgoing message with properties {subject:"[" & longName & "] ,Gaming Alert", content:"[" & longName & "] has been gaming, he is to report to I.T. by the end of the day", visible:true}
                        tell theNewMessage
      make new to recipient at end of to recipients with properties {address:"[email protected]"}
      send
                        end tell
              end tell
    end if
    end
    repeat
              if appIsRunning("safari") then
                        display dialog "Gaming is not allowed, Your log of your computer programs running has been emailed to the I.T. department. Please visit the I.T. department immedietly to remove this message" buttons {"Report To I.T."} default button 1 cancel button 1 with title "Gaming Alert" with icon stop
              end if
    end repeat
    if appIsRunning("safari") then
              tell application finder
                        quit appIsRunning("safari")
              end tell
    end if
    on appIsRunning(appName)
              tell application "System Events" to (name of processes) contains appName
    end appIsRunning
    end
    Any help is greatly appriciated
    Thanks! 

    I really do not appreciate your negativity towards this assignment.
    firstly i am not trying to "cheat" the system by asking for help, our teacher encourges us to go online , reserch and go onto forums such as these.
    Secoundly , I dont need you to criticize my idea's by telling me that i am a "taddle tale" or whatever
    Thirdly , it's called updating over wifi. Thats how I intend on updating the blacklist to new games
    Finally it will encourage student productivity, as without games there will be no distractions. Internet games and such are blocked and I plan to keep my identity, as the creator of the script , a secret
    And also, here's a bit of criticism maybe you would be a better educationalist yourself if you actually encouraged a project.
    Ps. Are you familiar with google science fair... if not LOOK IT UP!
    im going i have talked viney kumar and are most likley teaming up to put this project in action, we go to the same school. He thinks it is a good idea and if YOU ever had any idea's at all that aren't criticism maybe you would have at least one atom that is up to his standard of innovation.bye the way, i am only 14.What were you trying to do when YOU were 14...
    Signed
    Steves Assistant

  • How can i use Itunes to update more than one IPad with more than one owner

    How can i use Itunes to update more than one IPad with more than one owner?  I own an IPad and my wife owns an IPad.  I want to use my system to update both IPads.  We have different Apple Accounts and different applications.  Is this possible?

    Of course, that is too easy.  I am such a bonehead.

  • How do I schedule an automator script to run at a certain time every day?

    How do I schedule an automator script to run at a certain time every day?
    This used to be done through iCalendar and this option is no longer available.
    How do I do this?
    --Kenoli

    Kenoli Oleari1 wrote:
    How do I schedule an automator script to run at a certain time every day?
    This used to be done through iCalendar and this option is no longer available.
    How do I do this?
    --Kenoli
    You can use lauchd to run the script.
    Here's an example of an Automator App that I have scheduled to run at 7am daily:
    You would save this as com.yourname.plist and put it the the Folder: ~/Library/LaunchAgents/ (then log out and back in, or reboot)
    (To run a workflow, change open to automator)
    (A nice GUI launchd editor is Lingon)
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
              <key>Label</key>
              <string>com.tonyt.EventReport</string>
              <key>ProgramArguments</key>
              <array>
                        <string>open</string>
                        <string>/Users/Tony/Library/Scripts/Events Report.app</string>
              </array>
              <key>StartCalendarInterval</key>
              <dict>
                        <key>Hour</key>
                        <integer>7</integer>
                        <key>Minute</key>
                        <integer>0</integer>
              </dict>
    </dict>
    </plist>

  • Can I use Apple Script to press a button?

    Is there some way I can create an Apple Script to run and press a button in another application, or create a "plug-in" type script for the program to make the button into a something that can be used by a keyboard shortcut?
    I ask because I have an application that I can use to operate my digital camera, however, the button that Auto-Focuses then Shoots a photo does not have a keyboard shortcut. This is a problem because I also have the App "Snatch" on my iPhone, and, long story, short, I discovered I could use Snatch on my laptop on an Ad-Hoc network from about 1,000 feet away, maybe more. If I could find a way of making the "AF and Shoot" button into a keyboard shortcut, or create a script that could be triggered by a keyboard shortcut to press the button, I could use Snatch to control my camera remotely, far better then any part I would by from Nikon, or a third-party (Trust me, I have used a lot of them, and this method beats them all, save for the fact that I can't use bulb.)
    Anyway, thanks for any input, if any.

    Even if an application is not scriptable, you can generally use [GUI Scripting|http://www.macosxautomation.com/applescript/uiscripting/index.html] to press a button. For example, using Canon's RemoteCapture DC software, the script below will press the "Release" button of the main window:
    tell application "RemoteCapture DC" to activate
    tell application "System Events"
    tell process "RemoteCapture DC"
    click button 4 of window "RemoteCapture DC"
    end tell
    end tell
    If you then put the above script in the AppleScript menu in the menu bar, you should be able to use a third party application, like Quicksilver, to assign a keyboard shortcut to it.
    Message was edited by: Pierre L.

  • Automator or Apple Script To Move Multiple Files to Multiple Folders

    I was just wondering, is there any sort of automator workflow or maybe apple script that will allow me to automate the following:
    I have a folder named SCANS containing multiple different files that need to go to multiple different folders.
    So Say I have:
    SCANS
    and in this folder I have ten files named A,B,C,D,E,F,G,H,I,J and I want each of these files to be moved to different folders eg.
    A I want to go to folder 1
    B I want to go to folder 2
    C I want to go to folder 3 etc etc.
    Anyone know if there is a way of doing this please?
    I have tried a workflow where I find finder items in the Scans folder and move to another but that only seems to work for one file.  When I add more it does not seem to work.
    Any help/guidance would be appreciated.
    Thank you!

    Hi Niel,
    Not quite what I wanted because I missed some information from my question....
    What I actually want is to search for files containing certain text in the name and if positive to then move that file to the specified folders.
    Cheers.

  • 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

Maybe you are looking for