Applescript to create an address list text file

I need a script to look through a selected group and get the first and name, and the 'street address' of the address whose label is 'primary'.  I want to save this list as a CSV file, with a comma seperating the name from the street, and a new line/carriage return after each entry.  I've done a little with applescript, but I can't quite figure this one out.  Here's what I've got so far:
tell application "Address Book"
          set _groups to name of every group
          choose from list _groups with title "Create Address List" with prompt "Select an Address Book Group"
          set theirChoice to result as string
          set theContacts to (people in group theirChoice)
          repeat with thePerson in theContacts
  display dialog theirChoice
  --get addresses & names here
          end repeat
end tell
Thanks for the help.

After more searching, I found this which will take care of adding the text to the text file.  I just need to figure out how to get the streetAdress from the Address whose label is 'Primary'
set newText to "Name, streetAdress"
--newText will be the current contact's name/address info, and the next line adds it to the text file
do shell script "echo " & quoted form of newText & " >> ~/Desktop/PlainText.csv"

Similar Messages

  • How to create a tab-delimited text file?

    Hi,
    I need to create a tab-delimited text file at presentation server getting content from an internal table. My file should also have a header - also tab-delimited. Data for a header is stored in some work area.
    Any ideas how to add tab-delimiter into a text file? Or should I go for a HEX file and use
    CONSTANTS: c_tab TYPE x VALUE '09'.
    and separate my data with this constant instead?
    Any thoughts whould be appreciated.
    TIA
    Ivaylo Mutafchiev

    Hi Ivaylo,
    Refer sample code:
        IF i_final_head[] IS NOT INITIAL.
          CALL FUNCTION 'GUI_DOWNLOAD'
            EXPORTING
              filename                = lcl_filename
              filetype                = 'ASC'
              write_field_separator   = 'X'
            TABLES
              data_tab                = i_final_head
            EXCEPTIONS
              file_open_error         = 1
              file_read_error         = 2
              no_batch                = 3
              gui_refuse_filetransfer = 4
              invalid_type            = 5
              no_authority            = 6
              unknown_error           = 7
              bad_data_format         = 8
              header_not_allowed      = 9
              separator_not_allowed   = 10
              header_too_long         = 11
              unknown_dp_error        = 12
              access_denied           = 13
              dp_out_of_memory        = 14
              disk_full               = 15
              dp_timeout              = 16
              OTHERS                  = 17.
          IF sy-subrc <> 0.
            MESSAGE s000 WITH text-031.
            EXIT.
          ENDIF.
        ENDIF.
    Reward points if this helps.
    Manish
    Message was edited by: Manish Kumar

  • Can I create nested address lists?

    I want to create a set of nested address lists so that I can manage a largish group of contacts in a voluntary organisation with a hierarchy, rather like the way I manage contacts in Work using MS Outlook (sorry for mentioing the competition!). I tried adding an existing list (call it List1) to a new list (call it List2) which also has to carry some additional individual contacts. When I do this, "List2" shows the individual contacts and "List1" as well; when I select it for the "To:" line in a new email, "List2" appears OK, however when I send the email it is only sent to the individuals and does not go to the members of "List1".
    Am I doing something wrong or does Thunderbird not support this?

    Basic info on 'Address Book'.
    There are two default address books which you cannot delete.
    'Personal Address Book' and 'Collected Addresses'.
    You can add further 'address books'.
    File > New > Address Book.
    Enter a name and click on OK
    Address books can be created to hold specific contacts eg: Family, Clients or if you have a lot of people you can sub divide them.
    eg: A - M in one and N-Z in another
    You can also create 'Mailing Lists'.
    Mailing Lists are sub groups to an address book.
    Mailing lists are designed to allow selected contacts that are already in the address book be grouped together so that you can send one email to that group of people in your address book.
    So, a person in a 'Mailing List' must also be in the associated address book and must have a valid email address.
    More info on Mailing Lists here:
    * https://support.mozilla.org/en-US/kb/how-create-and-use-mailing-lists

  • Creating a link to text file in a tomcat server not working in JSP webapp

    I am using netbeans to create an web application within my desktop, and then I load the build/web folder to a tomcat server to test the application. Everything works fine. However, when I try to link up my JSP pages to text files (.txt) create by the application on the server, I seem to be getting files that might be kept in a terminal.
    When I get the Real path of the servlet context, I find that it is to a C:\ type file rather than a //hostname type of directory. So obviously those files are not being reached.
    Does anybody know how to deal this problem?

    There are a number of ways to get to the Flash Global Security settings dialog.
    My favourite way is just to double click on a Captivate SWF (not the HTM file) to open it in a web browser, then right click on the playing screen to get the Flash context menu.  On the context menu, click the Global Settings option.
    In the web page that opens, click the link on the left to Global Security Settings.
    Add the folder or drive location of your published Captivate content to the Trusted Locations.

  • How to create spaces in a text file

    Hi forum
               i am creating a text file with the GUI_DOWNLOAD function, my problem is that i need to create some lines with spaces at the end of the line. But i can´t, i had concatenate spaces and i have created structures but in the file doesn´t appear that spaces to the end of the line. example
    -  line
      abcdefghij
    - i need
      abcdefghij******************
    = space
    tghnks
    Josue

    Thnks Pawan, the correct code to append spaces to the end of line for save in a file is, this is an example:
       <b>DATA: space_character type c.</b>
       DATA: s_var1 type c(10).
    *  Init the space character
       <b>space_character  = cl_abap_char_utilities=>minchar .</b>
       s_var1 = '123'.
    *   we need seven spaces more to complete the length of s_var1, then :
    * We need to concatenate into field
    DO 7 TIMES.
        <b>CONCATENATE s_var1 space_character INTO s_var1.</b>
    ENDDO.
    * Move to the internal table for save the text in a file
    MOVE s_var1 TO t_out-line.
    APPEND t_out.
    * Finally we call the GUI_DOWNLOAD function
      CALL FUNCTION 'GUI_DOWNLOAD'
        EXPORTING
          filename                        = fullpath
          filetype                        = 'ASC'
        TABLES
          data_tab                        = t_out
        EXCEPTIONS
          file_write_error                = 1
          no_batch                        = 2
          gui_refuse_filetransfer         = 3
          invalid_type                    = 4
          no_authority                    = 5
          unknown_error                   = 6
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    And it´s all... looks easy but many partner doesn`t know
    Josué
    Code Formatted by: Alvaro Tejada Galindo on Jan 18, 2010 3:34 PM

  • How to create a mapping with text file as my target

    I need to create a mapping with source as a table and target as a text file.
    I am using OWB 10g R2. with database Oracle10g.
    Any one can help me to create a mapping with a text file as target.

    Hi,
    just create a File-Location and File-definition and use this file-operator as target object inside your mapping.
    Regards jwehner

  • How do I create and display a text file?

    Hello friends,
    I am trying to create a simple unix like operating system with very basic functionality. I have a hard time trying to create a "mktext" file and actually display the contents of the text file with the "cat" command. For example:
    // If I type
    $$ mktext test.txt "We are one"
    $$ Text file is created
    // And if I type
    $$ cat test.txt
    // This line will appear
    $$ "We are one" // Only the contents of the test.txt will display.
    That is what I want to do, but currently stuck. I would appreciate any help and suggestions. Thanks...

    This will do it:
    import java.io.*;
    import java.util.*;
    public class Osys
         BufferedReader keyboard = new BufferedReader(new InputStreamReader(System.in));
    public Osys()
         try
              while(true)
                   System.out.print("$$ ");
                   String s = keyboard.readLine();
                   analize(s);
         catch(Exception e){}
    private void analize(String s)
         if (s.trim().equals("")) return;
         StringTokenizer st = new StringTokenizer(s," ");
         if (!st.hasMoreTokens()) return;
         String s1 = st.nextToken();
         if (s1.equals("cat"))
              if (st.hasMoreTokens()) readIt(st.nextToken().trim());
              System.out.println("");  
              return;
         if (s1.equals("mktext"))
              if (st.hasMoreTokens()) writeIt(st.nextToken().trim(),s);
              System.out.println("");
              return;
    // write
    private void writeIt(String file, String line)
         BufferedWriter writer;
         StringTokenizer st = new StringTokenizer(line,"\"");
         if (st.countTokens() != 2) return;
         st.nextToken();
         try
              writer  = new BufferedWriter(new FileWriter(file));
                 writer.write(st.nextToken()); 
              writer.close();
              System.out.println("$$ Text file is created");  
         catch (IOException e)
               System.out.println(""+e);  
    // read
    private void readIt(String file)
         BufferedReader reader = null;
         String         read   = null;
         try
             reader = new BufferedReader(new FileReader(file));
              while( (read = reader.readLine()) != null)
                  System.out.println("$$ "+read);  
              reader.close();
         catch (IOException e)
               System.out.println(""+e);  
    public static void main(String[] args)
         new Osys();
    }Noah

  • Easiest way to import a bunch of addresses from text file to address book?

    What is the easiest way to import text files to address book?
    I have a Microsoft Word file with all of my addresses set-up like this:
    Johnny Appleseed
    Apple Computer
    1234 main St.
    Anytown, CT 06905
    203-321-4709
    [email protected]
    Is there some easy way to get them in there without having to copy & paste into each individual field.
    Thanks!

    See this thread.
    AK

  • How to create printable (PDF?) text file in PSE 7

    Using slide show format it is possible to create a text file for use in the slide show. Is it possible to print that file (Slide)? How?

    You can output the slideshow as PDF also for publishing purpose. Here is the help link on how to do the same
    http://help.adobe.com/en_US/elementsorganizer/using/WS8346320B-3F64-46f6-AE4B-9FF4D934DB36 _WIN.html#WS28EB9511-B6BE-4abd-980B-59A6DDC877A6_WIN
    Also you can use Share->PDF Slideshow option to create pdf slideshow for your images.
    Hope it helps.
    Thanks,
    Gaurav

  • Address Book text file import

    I'm trying to import contacts from MS Outlook 2002 to my address book via a csv text file. Apple Help says to make sure that csv files do not contain line brakes, but it doesn't say what is supposed to separate lines (i.e. contacts) in the file. Any thoughts

    Thanks. Thunderbird allowed me to export to LDIF, Address book can import.
    Do you know of anyway to import to a specfic group in Address book? As I import these they all end up in the ALL group and I have to manually find them and sort them.

  • Can I create a xml or text file?

    Hi,
    I would like to be able to create a text file or xml file
    using users input(this is not for a web site so do have server
    capabilities)
    The file will be smiler to this with the user input in {}
    Thanks for all your help

    Hey there,
    Flash being a web based application doesnt allow writing any
    files other than temp cookies or the ASO files. Now these files are
    useless for the medium you are describing here.
    Due to security reasons flash doesnt support XML/Text
    writing, but has very good support on the reading XML/Text file. If
    you are using the idea for a website then, maybe PHP, ASP along
    with SQl might help you save data from flash to a database. And if
    you have ideas of keeping this idea desktop based, maybe you can
    use MDM Zinc, even PHP, or Visual Studio (where ExternalCallbacks
    can be used).
    You can decide.

  • Address Book: Text File Import broken??

    In the Apple Address Book application, the File > Import > Text File... does not work for me. I get the field-mapping dialog and I can match up the fields OK, but then:
    + The OK button doesn't do anything (that I can tell).
    + Clicking the right arrow to see the first imported record works, but the left arrow is still grayed out. If I keep clicking the right arrow until I reach the last record, the right arrow grays out and the left arrow is enabled and I can back up. When backing up, both arrows are correctly enabled.
    + When browsing through the records, the spinning gear next to the arrows appears and never disappears, even though the next card has been displayed and I can go to the next card.
    + Cancel does work, and seems to be the only thing I can do.
    Can someone confirm this behavior? It smells like first-draft code, and I can't believe that Apple would ship something this buggy.
    If it matters: the file I'm trying to import is a csv exported from Thunderbird. Please don't tell me to use ldif; the ldif import misses a bunch of fields, which is why I wanted to use the text import where I control the field mapping myself.
    Thanks in advance,
    -- Philip

    I have no solution, but I've encountered the same behaviour with the spinning wheel, grayed out back arrow and the other symptoms you describe with a Tab-Text file. The spinning wheel appears as soon as I try to assign an address field, while names, phone numbers and such seem to correctly preview, though no import happens. Most annoying.

  • Exporting e-mail addresses as text file

    Hi, I've done a forum search, found lots of posts but none 'solved'.
    I want to export all the e-mail addresses from Address Book as a simple .txt file

    There may be a more direct way, but one thing you can do...
    1.[Optional] Create a Smart Group with criteria - [Email] [is Set]
    2. Go to Print - set Style to List and uncheck everything except email
    3. From the Print dialog, Save As PDF
    4. Open the PDF and select/copy all the text
    5. Open TextEdit and Paste
    6. Use a Find&Replace, if desired, to remove or separate the email identifier (work, home, etc)
    If, by chance, you want just the email addresses -not the associated names- you can go through Mail instead.
    1. Drag the Group to the To: of a new message
    2. Ctrl-click the Group name and Expand Group
    3. Select them with the mouse
    4. Copy
    5. Paste into TextEdit

  • How to create Dynamic Selection List containg file names of a directory?

    Hi,
    I need a Selection List with a Dynamic List of Values containing all file names of a particular directory (can change through the time).
    Basically, I need an Iterator over all file names in a directory, which could be used for Selection List in a JSF form.
    This iterator has nothing to do with a database, but should get the names directly from the file system (java.io.File).
    Can anybody tell me how to create such an iterator/selection list?
    I am working with JDeveloper 10.1.3.2, JSF and Business Services.
    Thank you,
    Igor

    Create a class like this:
    package list;
    import java.io.File;
    public class fileList {
        public fileList() {
        public String[] listFiles(){
        File dir = new File("c:/temp");
        String[] files = dir.list();
        for (int i = 0; i < files.length; i++)  {
                System.out.println(files);
    return files;
    Right click to create a data control from it.
    Then you can drag the return value of the listFiles method to a page and drop as a table for example.
    Also note that the Content Repository data control in 10.1.3.2 has the file system as a possible data source.

  • How to create and handle a text file in CVI

    Is there any way to create and handle (like...open,write,read,truncate,close)  the .txt file in CVI?

    Sure. CVI is a regular C compiler and hence you can use all ANSI C functions. In addition you can use the File I/O functions from the utility library.

Maybe you are looking for

  • ORA-00600: internal error code, arguments: [12333], [0], [0], [0], [], [],

    ORA-00600: Occurred in production database. I did not contact oracle support yet, because I know they will ask to upgrade or apply a patch. I want do that as a last resort. Do you see any other reason for this ORA-600 error or solution? Thanks. part

  • Empty file, java mapping issue

    Hello, does anyone have an ide how to create java mapping to create empty file on FTP? Why this code always send NUL character = 1byte and not 0 byte as needed? public void execute(InputStream in, OutputStream out) throws StreamTransformationExceptio

  • Problems opening EPS-files in Illustrator CS5.1

    I have problems opening some EPS-files that I downloaded from Shutterstock. Their support person told me to contact your support. I'm using Illustrator CS5.1 on a PC. When I try to open the files Illustrator's suddenly not responding and I have to cl

  • License Issue

    hi,     I have 2 proffessional license and I want to use these license in my 2 companies. But for this I need that both companies have same user. But when i tried to create same user in another company I got the error message "entry already exist in

  • When button pressed, update

    I have a criteria as I created a button 'cancel' with 'when_button_pressed' trigger. IF i press the button cancel , then the table should be updated setting the cancelled_flag column to 'YES' Which is initially by default as 'NO'. But when i press th