Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Applescript help?

Applescript help?
Thread Tools
Fresh-Faced Recruit
Join Date: Mar 2010
Status: Offline
Reply With Quote
Mar 9, 2010, 01:52 PM
 
Hello all. I need some help. I have a mailing list for my business and the way email addresses are entered is like this:

"email","date","ip"

So a quick example would be:

"bob@bob.com","1268080664","XX.XXX.XXX.XXX"

I don't want to use the online email sender, I want to use one one on my mac. I set up automator to download the text file the info is stored in, but then I need it to delete some necessary functions. Before you ask, "Why not just make your PHP file remove the extra stuff?" and my answer is that I want to keep it there incase I use it in the future. So basically, I am wondering how in applescript, I can have it remove everything but the email address. The email is always laying between the first two quotes, so that might make it easier.

If you can help, thank you very much. If not, can you refer me to where I can get help?
     
Mac Elite
Join Date: Feb 2000
Location: Nashua NH, USA
Status: Offline
Reply With Quote
Mar 9, 2010, 03:46 PM
 
     
Junior Member
Join Date: May 2007
Status: Offline
Reply With Quote
Mar 9, 2010, 03:54 PM
 
set x to "\"bob@bob.com\",\"1268080664\",\"XX.XXX.XXX.XXX\" "
set y to text 2 thru -1 of x
set o to offset of "\"" in y
if o > 1 then set e to text 1 thru (o - 1) of y

-->returns bob@bob.com
     
Fresh-Faced Recruit
Join Date: Mar 2010
Status: Offline
Reply With Quote
Mar 10, 2010, 02:00 PM
 
I got this help from another board:

set theData to paragraphs of (read file "path:to:your.txt")
set emailAddresses to {} -- somewhere to store the addresses when we're done
set {old_delims, my text item delimiters} to {my text item delimiters, "\""} -- setup the TIDs
repeat with eachLine in theData
copy text item 2 of eachLine to end of emailAddresses -- extract the email address
end repeat
set my text item delimiters to old_delims -- clean up when we're done


How would I then have it save it as a second text file, named email2.txt?
     
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Mar 10, 2010, 05:03 PM
 
If this mailing list is large, you can parse the addresses faster in the Unix command line than Applescript, and you would be better off not sending this from a desktop email client if you are interested in sending HTML mail and not having your message flagged as spam and/or not figuring out the max recipients in a single message supported by your email service provider.
     
Dedicated MacNNer
Join Date: Jul 2002
Status: Offline
Reply With Quote
Mar 25, 2010, 02:04 PM
 
Originally Posted by PXL Creations View Post
I got this help from another board:

set theData to paragraphs of (read file "path:to:your.txt")
set emailAddresses to {} -- somewhere to store the addresses when we're done
set {old_delims, my text item delimiters} to {my text item delimiters, "\""} -- setup the TIDs
repeat with eachLine in theData
copy text item 2 of eachLine to end of emailAddresses -- extract the email address
end repeat
set my text item delimiters to old_delims -- clean up when we're done


How would I then have it save it as a second text file, named email2.txt?
You could also use this:

set filePath to "/path/to/file.txt"
set savePath to "/path/to/file_save.txt"
do shell script "awk -F\",\" '{print $1}' " & filePath & " | sed 's/\"//g' > " & savePath

This'll export your results to a the text file "file_save.txt"
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 07:54 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2