Page 1 of 1

Moving attachments of one email

PostPosted: Tue Dec 07, 2010 5:02 pm
by m0mo
Hello guys,

I'm very new to Hazel and Applescript and currently my rules are pretty easy. Today I got a nice idea for an automation:

I often get emails with a lot of attachments with different names and extensions. I save them to my download folder and often have to
move them to a project folder. The trouble starts where I have to remember which file where linked to which email and sometimes its a very annoying task.

What I would like to have is that when i save multiple attachment at onces that hazel creates a folder named by the email sender (denoted in the source when i press apple+i on the file) and move all attachments belonging to that mail into it.

Okay, so here I am with no clue how to realise that. I am pretty sure i need a bit of applescript because of the general approach (not a specific email) but how to start? What should be scripted, what is Hazel's task?

I am very grateful vor some advices, similar scripts or code snippets!
best regards from germany
m0mo

Re: Moving attachments of one email

PostPosted: Wed Dec 08, 2010 4:19 pm
by dhy8386
From what you have described, there may just be too many variations to automate everything but here are some suggestions on where to start.

1) I do not think Hazel can create folders without using an applescript or shell script but lets say you already know the project names and thus have created folder names for them (Ie Project A and Project B). You can have hazel sort into these folders based on properties of the downloaded files

2) I believe Hazel will recognize the "Where From" attributes if you used the property called "Source URL/Address". So for example if you are using the senders name as the distinguishing property your rule could look something like:

Running on the Downloads Folder

If all conditions true:
If Source URL/Address contains jsmith@email.com

Do the following:
Move file to folder Project A

Now you may have to decide if the full email address is too specific. Maybe you want to change the condition to if any of the following are true and list out a bunch of ways the Where From could read (ie John Smith, jsmith, jsmith@email.com, etc). The downside if you consider it as such is that if your have hundreds of emails that go into hundreds of projects then you will need a rule for each. Clearly, in this case, an applescript may be more efficient.

3) I also advise that in your case, color coding using the "Set color label" to property may be beneficial. So maybe you have a rule that is a meta rule for coding files based on extensions or some other important attribute. Again, it all depends on which attributes are important and if redundancy is necessary/a good thing in your case.

I might start there to see how it works. Also, a great site for exploring applescript is macscripters.net. Lots of sample code and people willing to help out. Maybe someone else here can help out with creating a simple script that looks at the Where From attribute and creates a folder if one is not already created.

Re: Moving attachments of one email

PostPosted: Wed Dec 08, 2010 4:44 pm
by Mr_Noodle
Well, you could sort into subfolders based on the source url/domain. For email attachments, it should be end up being the sender's email address. I suggest trying it out on some test attachments and seeing how it works out.

Re: Moving attachments of one email

PostPosted: Thu Dec 09, 2010 7:06 am
by m0mo
Hello dhy8386,

dhy8386 wrote:1) I do not think Hazel can create folders without using an applescript or shell script but lets say you already know the project names and thus have created folder names for them (Ie Project A and Project B). You can have hazel sort into these folders based on properties of the downloaded files


that is something i wanted to avoid - of course I could create seperate rules with fixed folders/project name/etc, but i wanted to do it automtically. So i think here is the place for applescript.

dhy8386 wrote:Now you may have to decide if the full email address is too specific. Maybe you want to change the condition to if any of the following are true and list out a bunch of ways the Where From could read (ie John Smith, jsmith, jsmith@email.com, etc). The downside if you consider it as such is that if your have hundreds of emails that go into hundreds of projects then you will need a rule for each. Clearly, in this case, an applescript may be more efficient.


exactly. :)

dhy8386 wrote:3) I also advise that in your case, color coding using the "Set color label" to property may be beneficial. So maybe you have a rule that is a meta rule for coding files based on extensions or some other important attribute. Again, it all depends on which attributes are important and if redundancy is necessary/a good thing in your case.


I thought about that, too. Currently I labeled all email attachments with one color - I could try to rewrite it that it groups attachments by the emailadress and label them with different color. What i do not like with labeling is the fact that once I have removed it from the place where I needed the color it is still colored in other location.

dhy8386 wrote:I might start there to see how it works. Also, a great site for exploring applescript is macscripters.net. Lots of sample code and people willing to help out. Maybe someone else here can help out with creating a simple script that looks at the Where From attribute and creates a folder if one is not already created.


thanks for your great tipps and suggestions, but www.macscripters.net seems not to work - is it the correct name?

best regards
m0mo

Re: Moving attachments of one email

PostPosted: Thu Dec 09, 2010 12:13 pm
by sjk
Maybe dhy8386 meant http://macscripter.net/.

Moving attachments of one email

PostPosted: Sun Mar 06, 2011 9:26 pm
by hawasakigirl
I have thousands of email addresses organized into 60 or so groups in Entourage. I need to export them. Id like to get my groups from Entourage on my old computer into Mail on my new one. Ive tried everything. Does anyone know how it can be done? AuntieChe

Re: Moving attachments of one email

PostPosted: Wed Mar 09, 2011 5:59 pm
by Mr_Noodle
I'm not sure how this relates to Hazel. You should look into email/addressbook migration tools. Also, it's not relevant to this thread. I advise you create your own thread if you have your own question to ask.