Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

Applescript help..... lot's of help.

Thread Tools
 
Search this Thread
 
Old 28 June 2005, 10:42 PM
  #1  
angrynorth
Scooby Regular
Thread Starter
 
angrynorth's Avatar
 
Join Date: Oct 2004
Location: Was Manc now Camden
Posts: 2,689
Likes: 0
Received 0 Likes on 0 Posts
Wink Applescript help..... lot's of help.

I really should know more about Applescript, but I have a problem that I think Applescript could easily fix and I don't know where to start with it . I keep telling myself I will learn it but never get the time.

What I would like to do is extract the body text from a batch of email messages from one account and copy it all into a plain text document then remove any instances of the % symbol.

I tried it in Automator but the results aren't great, it keeps the header information which I don't want to display. Here is an example of the automator results so you can at least see the context.

If anyone can help me out I will buy you an ice cream next time I see you

Ta, Andy.

-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

DATE: Tue, 28 Jun 2005 23:10:47 +0200
SENDER: HomeInfo <donotreply@homeinfo.co.uk>
SUBJECT: Search at HomeInfo.co.uk
RECIPIENT: backup@homeinfo.co.uk

Guest User search at HomeInfo.co.uk


Following is the search criteria...

Location : manchester
Keywords : city centre
Min. Price : 80000
Max. Price : 120000



-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

DATE: Tue, 28 Jun 2005 23:04:56 +0200
SENDER: HomeInfo <donotreply@homeinfo.co.uk>
SUBJECT: Search at HomeInfo.co.uk
RECIPIENT: backup@homeinfo.co.uk

Guest User search at HomeInfo.co.uk


Following is the search criteria...

Location : uttoxeter
Keywords : jayman




-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

DATE: Tue, 28 Jun 2005 22:59:33 +0200
SENDER: HomeInfo <donotreply@homeinfo.co.uk>
SUBJECT: Search at HomeInfo.co.uk
RECIPIENT: backup@homeinfo.co.uk

Guest User search at HomeInfo.co.uk


Following is the search criteria...

Location : bridlinton
Min. Price : 100000
Max. Price : 200000




-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

DATE: Tue, 28 Jun 2005 22:59:26 +0200
SENDER: HomeInfo <donotreply@homeinfo.co.uk>
SUBJECT: Search at HomeInfo.co.uk
RECIPIENT: backup@homeinfo.co.uk

Guest User search at HomeInfo.co.uk


Following is the search criteria...

Location : temple%cloud
Keywords : rural
Min. Price : 0
Max. Price : 170000




-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Old 29 June 2005, 02:38 PM
  #2  
Markus
Scooby Regular
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
Default

Andy,
Can you email me a copy of the automater script and I'll have a look at it, hack it apart, swear at the machine, run it through script debugger, put it back together, and try and make it do what you want.

I can't promise miracles, but I'll give it a go.
Old 29 June 2005, 06:43 PM
  #3  
Markus
Scooby Regular
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
Default

Andy,
You have a PM, i've got a little present for you
Old 29 June 2005, 07:08 PM
  #4  
angrynorth
Scooby Regular
Thread Starter
 
angrynorth's Avatar
 
Join Date: Oct 2004
Location: Was Manc now Camden
Posts: 2,689
Likes: 0
Received 0 Likes on 0 Posts
Default

Cheers Markus, I just tried to reply but your mailbox is full, Mr Popular.

My email is andy@homeinfo.co.uk and if what you said in pm is true then you are an absolute hero!

Cheers
Andy
Old 29 June 2005, 07:25 PM
  #5  
Markus
Scooby Regular
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
Default

Andy,
PM is now empty

I'll email you anyway, as I need to send an attachment.
Old 29 June 2005, 07:37 PM
  #6  
angrynorth
Scooby Regular
Thread Starter
 
angrynorth's Avatar
 
Join Date: Oct 2004
Location: Was Manc now Camden
Posts: 2,689
Likes: 0
Received 0 Likes on 0 Posts
Default

YOU ARE A GENIUS.



Thanks so much this is more of a help than you would believe and it works a dream!

Cheers
Andy
Old 29 June 2005, 07:55 PM
  #7  
class_A
Scooby Regular
 
class_A's Avatar
 
Join Date: Apr 2002
Location: elsewhere
Posts: 1,212
Likes: 0
Received 0 Likes on 0 Posts
Default

Scoobynet beats Ars then? I am poo at Applescript, but am curious as to the solution!
Old 29 June 2005, 07:56 PM
  #8  
Markus
Scooby Regular
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
Default

Glad to be of service, and the ice cream is rather tasty
Old 29 June 2005, 10:18 PM
  #9  
angrynorth
Scooby Regular
Thread Starter
 
angrynorth's Avatar
 
Join Date: Oct 2004
Location: Was Manc now Camden
Posts: 2,689
Likes: 0
Received 0 Likes on 0 Posts
Default

Originally Posted by class_A
Scoobynet beats Ars then? I am poo at Applescript, but am curious as to the solution!
I was certain that Scoobynet would answer this first, as is always the case over at Ars they wanted to punt it into Terminal, which is even dafter.

Thanks for the help Markus!
Old 30 June 2005, 01:27 AM
  #10  
Markus
Scooby Regular
 
Markus's Avatar
 
Join Date: Mar 1999
Location: The Great White North
Posts: 25,080
Likes: 0
Received 0 Likes on 0 Posts
Default

punt it to terminal, lol, probably would have been something to do with using a perl script to achieve the same effect I did.

As for the solution, well, if you want a copy of the script, let me know. Essentially what I did was this:

* Ask Mail.app to give me the currently selected messages

* Create a repeat loop to repeat through the messages

* Ask mail for the "contents" ie; body of the message

* Use delimiters set to "new line" and search through the content of the current message one line at a time until I find a line that contains the word "Location" or "Keywords" as these are the lines that will contain the % character.

* When I find the two lines see if there is a % character by stepping, character by character through the line and seeing if it contains %, if it does, replace it with a space.
This is the slowest part of the script. If Applescript had a decent find and replace command then it would be much quicker (Acme script widgets does, and is great but costs )

* Whilst stepping through, I've been keeping the untouched lines, so I add the modified line(s), if they were modified, back into the block of data and then write it out to a file on the desktop

* repeat the above for all selected messages.

I would not consider myself an expert in AS but I do know a bit here and there.

My tips?

* Get Script Debugger, it's way, way better than Apple's Script Editor, or Xcode (unless you can line step debug scripts in xcode, not sure if you can, not tried for a while). Fully featured editor with debugging, I could not live without it

* Snoop around macscripter.net (think that's the place)

If you've any AS questions or need a script to do something, feel free to ask, I might be able to help out.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
JTaylor
Non Scooby Related
202
25 December 2016 09:14 AM
scoobhunter722
ScoobyNet General
52
20 October 2015 04:32 PM
Billet
ScoobyNet General
42
14 October 2015 10:38 PM
Wish
Computer & Technology Related
3
30 September 2015 10:39 PM
Nicky-nick
Middlesex Subaru Owner's Club
3
29 September 2015 02:02 PM



Quick Reply: Applescript help..... lot's of help.



All times are GMT +1. The time now is 01:06 PM.