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

Does anyone know of a way to create a Contact list with a defined amount of contacts? They can be dummy entries, but I just need to create an address book with > 2000 entries. An Automator script is what I have in mind, but I'm not sure how to go about this.

I apologize if this is in the wrong place. Was considering SU or SE, but figured I'd start here.

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

An Applescript can bulk-create OS X address book entries, which you can then import to your iPhone. I made up a basic one for you:

-- Change these to your desired data
set firstName to "Test"
set lastName to "User"
set numberOfEntries to "5" as integer

set counter to "1" as integer
tell application "Address Book"
    repeat numberOfEntries times
        set thePerson to make new person with properties {first name:firstName, last name:lastName & " " & counter}
        make new email at end of emails of thePerson with properties {label:"Work", value:"test" & counter & "@example.com"}
        make new address at end of addresses of thePerson with properties {label:"Home", city:"Fakeville", street:(counter as string) & " Some St."}
        set counter to counter + 1
    end repeat
    save
end tell

Open AppleScript Editor (in your Applications/Utilities/ folder) and paste that in to a new script. As is, it will make you 5 numbered contacts like so: example contacts

You can change the number in the set numberOfEntries to "5" as integer line to however many you need, and change the data if you wish. If you need other fields (like phone numbers), ask and I can show you how.

Improved version

I went a bit overboard and made a version that comes up with nicer names. I took the 20 most popular male and female names, 40 most popular last names, and added a middle initial, so you get a pretty low chance of duplicates (a bit under 5% in a set of 2000, by my math) without the goofy looking numbered contacts.

It also adds all the contacts to a group ("Test Group") so you can pick out all the dummy ones easily if you're adding to an existing address book and want to clean it up later.

Edit: I also changed it to prompt for how many items to create, so it's not necessary to edit the code.

-- name lists: 20 most popular (US) male and female first names, 40 most popular last names
set firstNameList to {"Mary", "Patricia", "Linda", "Barbara", "Elizabeth", "Jennifer", "Maria", "Susan", "Margaret", "Dorothy", "Lisa", "Nancy", "Karen", "Betty", "Helen", "Sandra", "Donna", "Carol", "Ruth", "Sharon", "James", "John", "Robert", "Michael", "William", "David", "Richard", "Charles", "Joseph", "Thomas", "Christopher", "Daniel", "Paul", "Mark", "Donald", "George", "Kenneth", "Steven", "Edward", "Brian"}
set lastNameList to {"Smith", "Johnson", "Williams", "Jones", "Brown", "Davis", "Miller", "Wilson", "Moore", "Taylor", "Anderson", "Thomas", "Jackson", "White", "Harris", "Martin", "Thompson", "Garcia", "Martinez", "Robinson", "Clark", "Rodriguez", "Lewis", "Lee", "Walker", "Hall", "Allen", "Young", "Hernandez", "King", "Wright", "Lopez", "Hill", "Scott", "Green", "Adams", "Baker", "Gonzalez", "Nelson", "Carter"}
set initialList to "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
set counter to "1" as integer

-- prompt for how many contacts to create
set dialogText to "Number of contacts to create?"
repeat
    display dialog dialogText default answer ""
    set numberOfEntries to text returned of result
    try
        if numberOfEntries = "" then error
        set numberOfEntries to numberOfEntries as number
        exit repeat
    on error

    end try
end repeat

-- populate the address book
tell application "Address Book"
    set theGroup to make new group with properties {name:"Test Group"}
    repeat numberOfEntries times
        set firstName to some item of firstNameList
        set lastName to some item of lastNameList
        set middleInitial to some item of initialList & "."
        set thePerson to make new person with properties {first name:firstName, middle name:middleInitial, last name:lastName}
        make new email at end of emails of thePerson with properties {label:"Work", value:firstName & middleInitial & lastName & "@example.com"}
        make new address at end of addresses of thePerson with properties {label:"Home", city:"Fakeville", street:(counter as string) & " Some St."}
        add thePerson to theGroup
        set counter to counter + 1
    end repeat
    save
end tell

Here's what it generates: dummy contacts 2

share|improve this answer
1  
Looks PERFECT! Thanks! I'll test it out and let you know if I need anything else! –  Thomas Aug 22 '12 at 19:26
    
Man I wish I could +1000 this for the extra effort. Thanks again!!! –  Thomas Sep 25 '12 at 17:00
    
You're welcome, glad it was useful. Sometimes it's fun to just put together a little script to solve one problem. –  robmathers Sep 25 '12 at 17:02
1  
I changed the "improved" version to include a prompt for the number of contacts to generate, rather than requiring the script to be edited. –  robmathers Sep 25 '12 at 18:40
add comment

Your Answer

 
discard

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

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