View Full Version : Applescript-Delete first few characters in a line

Nov 5, 2009, 07:42 PM
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?

Nov 5, 2009, 08:31 PM
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.


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