Applescript: Seperate string by carriage return

Discussion in 'Mac Programming' started by hiddenpremise, Nov 29, 2008.

  1. hiddenpremise macrumors regular

    hiddenpremise

    Joined:
    Jul 25, 2008
    Location:
    Somewhere between my imagination and reality
    #1
    Here is the gist of what I am trying to do
    Code:
    set x to do shell script "ls -a /"
    which returns
    Code:
    ".
    ..
    .DS_Store
    .vol
    Applications
    Desktop DB
    Desktop DF
    Developer
    Library
    Network
    System
    Users
    Volumes
    bin
    cores
    dev
    etc
    home
    install
    mach.sym
    mach_kernel
    mach_kernel.ctfsys
    mnt
    net
    php.ini
    private
    sbin
    tmp
    usr
    var"
    
    I then want to get each item that "ls" returns. The way it is returned, every item is on a separate line. There may be more than one word on a line, but it is still the same item, for instance "Desktop DB." Does anyone know how to separate by carriage return (I'm assuming that is \p or \r)?

    Thanks much,
    Whit
     
  2. HiRez macrumors 603

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
  3. hhas macrumors regular

    Joined:
    Oct 15, 2007
    #3

    Code:
    every paragraph of (do shell script "ls -a /")
     

Share This Page