Applescript-Delete first few characters in a line

Discussion in 'Mac Programming' started by dkalthoff, Nov 5, 2009.

  1. dkalthoff macrumors newbie

    Nov 5, 2009
    I have a basic understanding of what Applescript does, I have knowledge of AS2.0, HTML and a bit of Java.

    That being said, I have a list of about 150,000 addresses that I plan on mailing, but they are formatted with a few numbers before the actual address that are completely irrelevant. I want to have TextEdit delete the first 9 characters on every line (every address is on a separate line). In order to save some time, I tried to use the script builder to make a script to delete them for me but to no avail.

    Could anyone here help me?
  2. lee1210 macrumors 68040


    Jan 10, 2005
    Dallas, TX
    Not sure in applescript, but in shell:
    cat test.txt | awk '{print substr($0,10,length($0)-1)}'

    In this cast, test.txt looked like:
    012345678 ABC Tded Bd
    012345678 ABC Tded Cc
    012345678 ABC Tded Dd
    012345678 ABC Tded Ee
    012345678 ABC Tded Ff

    The output is:
    ABC Tded Bd
    ABC Tded Cc
    ABC Tded Dd
    ABC Tded Ee
    ABC Tded Ff

    You can redirect the output to a new file, and the job should be done.

  3. dkalthoff thread starter macrumors newbie

    Nov 5, 2009
    Thank you so much, you just saved me about a weeks worth of work.

Share This Page