powermail-discuss Digest #2747 - Wednesday, November 28, 2007 filing attachments (was Re: Script to delete orphaned attachments?) by "angel Kyodo williams | urbanPEACE" <[EMAIL PROTECTED]> Re: Script to delete orphaned attachments? by "Justin Beek" <[EMAIL PROTECTED]> Re: filing attachments (was Re: Script to delete orphaned attachments?) by "Justin Beek" <[EMAIL PROTECTED]> Re: Script to delete orphaned attachments? by "Ben Kennedy" <[EMAIL PROTECTED]> Re: Script to delete orphaned attachments? by "Marlyse Comte" <[EMAIL PROTECTED]> Re: Script to delete orphaned attachments? by "Ben Kennedy" <[EMAIL PROTECTED]> Re: Script to delete orphaned attachments? by "H.R. Riggs" <[EMAIL PROTECTED]>
---------------------------------------------------------------------- Subject: filing attachments (was Re: Script to delete orphaned attachments?) From: "angel Kyodo williams | urbanPEACE" <[EMAIL PROTECTED]> Date: Tue, 27 Nov 2007 11:18:27 -0800 I'm not certain if this feature has been requested, but it would be really helpful for me to be able to file attachments in their appropriate folders in my overall file structure rather than solely have things in PM's attachment folder where i have to move them (and potentially orphan them.) Does anyone know of a script that does this for now? angel Quoting Ben Kennedy <[EMAIL PROTECTED]>: > Justin, > > This sounds very useful. Can you share? > > -ben > > Justin Beek wrote at 10:33 AM (-0600) on 11/27/07: > >> I have a script that will move the attachments in the messages to separate >> folders based on the Message ID Number. >> >> After you run the script on all your messages, any files leftover *should* >> be safe to trash. >> >> It's a pretty nice script for Spring Cleaning. For example, if you have 5 >> messages with 5 attachments each, you'll end up w/ 5 folders instead of 25 >> files. >> >> Good Luck, >> Justin >> >> >> On 11/27/07 10:18 AM, "Bill Courington" <[EMAIL PROTECTED]> wrote: >> >>> Is there such a thing? I've got about a zillion files in the Attachments >>> folder and I'm pretty sure (not positive) that many of them belong to >>> trashed messages. >>> >>> Bill >>> >>> >>> >>> >> >> >> >> >> > > -- > Ben Kennedy (chief magician) > zygoat creative technical services > http://www.zygoat.ca > > > > PM 5.5.3 | OS X 10.5.1 | Powerbook G4/1.5 | 2G RAM | 80GB HD ---------------------------------------------------------------------- Subject: Re: Script to delete orphaned attachments? From: "Justin Beek" <[EMAIL PROTECTED]> Date: Tue, 27 Nov 2007 13:55:03 -0600 Here it is. It does have some issues: On older versions of PowerMail, having it set as an outgoing rule might crash PowerMail. And if you set it as a rule for all incoming, all the attachments will go into a folder named "-1" (issue w/ Finder & Powermail). I just run it every few weeks to *fix* the folders from the "-1" to the "correct" folder. Please be careful and test it before implementing. :) Justin Beek <START> global theFolder tell application "PowerMail" set attachFolder to attachment folder set theMessages to current messages repeat with msg in theMessages set msgStatus to status of msg set attachList to attachments of msg if (count items of attachList) > 0 then set theID to the ID of msg set msgAttachFolder to "" set msgAttachFolder to theID set msgAttachFolder to msgAttachFolder tell application "Finder" if not (exists folder (attachFolder & msgAttachFolder as string)) then set theFolder to (make new folder at attachFolder with properties {name:(msgAttachFolder as string)}) else set theFolder to folder (attachFolder & msgAttachFolder as string) end if end tell repeat with attachIdx from (count items of attachList) to 1 by -1 set attachFile to file of (item attachIdx of attachList) tell application "Finder" set newAttachFile to (move attachFile to theFolder without replacing) as alias end tell delete attachment attachIdx of msg make new attachment at msg with properties {file:(newAttachFile as alias)} end repeat end if end repeat end tell <END> On 11/27/07 12:37 PM, "Ben Kennedy" <[EMAIL PROTECTED]> wrote: > Justin, > > This sounds very useful. Can you share? > > -ben > > Justin Beek wrote at 10:33 AM (-0600) on 11/27/07: > >> I have a script that will move the attachments in the messages to separate >> folders based on the Message ID Number. >> >> After you run the script on all your messages, any files leftover *should* >> be safe to trash. >> >> It's a pretty nice script for Spring Cleaning. For example, if you have 5 >> messages with 5 attachments each, you'll end up w/ 5 folders instead of 25 >> files. >> >> Good Luck, >> Justin >> >> >> On 11/27/07 10:18 AM, "Bill Courington" <[EMAIL PROTECTED]> wrote: >> >>> Is there such a thing? I've got about a zillion files in the Attachments >>> folder and I'm pretty sure (not positive) that many of them belong to >>> trashed messages. >>> >>> Bill >>> >>> >>> >>> >> >> >> >> >> ---------------------------------------------------------------------- Subject: Re: filing attachments (was Re: Script to delete orphaned attachments?) From: "Justin Beek" <[EMAIL PROTECTED]> Date: Tue, 27 Nov 2007 13:57:20 -0600 I hate the renaming of attachments by PowerMail and I have petitioned for a fix a few time. It's not a real issue with anyone else, I guess. Justin On 11/27/07 1:18 PM, "angel Kyodo williams | urbanPEACE" <[EMAIL PROTECTED]> wrote: > I'm not certain if this feature has been requested, but it would > be really helpful for me to be able to file attachments in their > appropriate folders in my overall file structure rather than solely > have things in PM's attachment folder where i have to move them > (and potentially orphan them.) > > Does anyone know of a script that does this for now? > > angel > > > > Quoting Ben Kennedy <[EMAIL PROTECTED]>: > >> Justin, >> >> This sounds very useful. Can you share? >> >> -ben >> >> Justin Beek wrote at 10:33 AM (-0600) on 11/27/07: >> >>> I have a script that will move the attachments in the messages to separate >>> folders based on the Message ID Number. >>> >>> After you run the script on all your messages, any files leftover *should* >>> be safe to trash. >>> >>> It's a pretty nice script for Spring Cleaning. For example, if you have 5 >>> messages with 5 attachments each, you'll end up w/ 5 folders instead of 25 >>> files. >>> >>> Good Luck, >>> Justin >>> >>> >>> On 11/27/07 10:18 AM, "Bill Courington" <[EMAIL PROTECTED]> wrote: >>> >>>> Is there such a thing? I've got about a zillion files in the Attachments >>>> folder and I'm pretty sure (not positive) that many of them belong to >>>> trashed messages. >>>> >>>> Bill >>>> >>>> >>>> >>>> >>> >>> >>> >>> >>> >> >> -- >> Ben Kennedy (chief magician) >> zygoat creative technical services >> http://www.zygoat.ca >> >> >> >> > > > > PM 5.5.3 | OS X 10.5.1 | Powerbook G4/1.5 | 2G RAM | 80GB HD > > > > ---------------------------------------------------------------------- Subject: Re: Script to delete orphaned attachments? From: "Ben Kennedy" <[EMAIL PROTECTED]> Date: Tue, 27 Nov 2007 12:21:33 -0800 Great, thanks Justin! I tested this on a few messages and for the most part it seems to work great. Here are a couple more caveats I noticed: - if a message contains any deleted attachments, any other still- existing attachments will not be touched. - if an attachment has been already moved somewhere else on the filesystem (out of the default PM attachments folder), it will be nonetheless dutifully relocated back into the attachments folder. This is counter to what behaviour I would want. Probably a simple check for the attachment's current folder would alleviate this. - it might be cool if the names of the created subfolders were appended with e.g. the sender's e-mail address, and/or message date, to aid in quick management/cleanup from the finder. - if a future revision of PM would facilitate the proper behaviour when used as an incoming filter, that would be right fantastic. Unfortunately I am not adept enough with AS nor do I have the time right at the moment to try and implement these fixes myself, but I thought I would mention them in case anyone else is inclined. Great starting point though; I can see myself eventually using this regularly (particularly if it eventually works as an incoming filter)! -ben Justin Beek wrote at 1:55 PM (-0600) on 11/27/07: >Here it is. It does have some issues: > >On older versions of PowerMail, having it set as an outgoing rule might >crash PowerMail. > >And if you set it as a rule for all incoming, all the attachments will go >into a folder named "-1" (issue w/ Finder & Powermail). > >I just run it every few weeks to *fix* the folders from the "-1" to the >"correct" folder. > >Please be careful and test it before implementing. :) -- Ben Kennedy (chief magician) zygoat creative technical services http://www.zygoat.ca ---------------------------------------------------------------------- Subject: Re: Script to delete orphaned attachments? From: "Marlyse Comte" <[EMAIL PROTECTED]> Date: Tue, 27 Nov 2007 19:28:50 -0600 wanted to try this one - sounds very useful - but can't get it to compile, it gets a hiccup on "else set theFolder to folder..." any hints how to get it to compile? (I think I'm good on the line endings so far). ---marlyse ------------ former message(s) quotes: ------------- >Here it is. It does have some issues: > >On older versions of PowerMail, having it set as an outgoing rule might >crash PowerMail. > >And if you set it as a rule for all incoming, all the attachments will go >into a folder named "-1" (issue w/ Finder & Powermail). > >I just run it every few weeks to *fix* the folders from the "-1" to the >"correct" folder. > >Please be careful and test it before implementing. :) > >Justin Beek > ><START> > >global theFolder > >tell application "PowerMail" >set attachFolder to attachment folder > >set theMessages to current messages >repeat with msg in theMessages >set msgStatus to status of msg > >set attachList to attachments of msg >if (count items of attachList) > 0 then >set theID to the ID of msg >set msgAttachFolder to "" >set msgAttachFolder to theID >set msgAttachFolder to msgAttachFolder > >tell application "Finder" >if not (exists folder (attachFolder & msgAttachFolder as string)) then set >theFolder to (make new folder at attachFolder with properties >{name:(msgAttachFolder as string)}) >else > set theFolder to folder (attachFolder & msgAttachFolder as string) >end if >end tell >repeat with attachIdx from (count items of attachList) to 1 by -1 >set attachFile to file of (item attachIdx of attachList) >tell application "Finder" > set newAttachFile to (move attachFile to theFolder without replacing) as >alias >end tell >delete attachment attachIdx of msg >make new attachment at msg with properties {file:(newAttachFile as alias)} >end repeat >end if >end repeat >end tell > ><END> > >On 11/27/07 12:37 PM, "Ben Kennedy" <[EMAIL PROTECTED]> wrote: > >> Justin, >> >> This sounds very useful. Can you share? >> >> -ben >> >> Justin Beek wrote at 10:33 AM (-0600) on 11/27/07: >> >>> I have a script that will move the attachments in the messages to separate >>> folders based on the Message ID Number. >>> >>> After you run the script on all your messages, any files leftover *should* >>> be safe to trash. >>> >>> It's a pretty nice script for Spring Cleaning. For example, if you have 5 >>> messages with 5 attachments each, you'll end up w/ 5 folders instead of 25 >>> files. >>> >>> Good Luck, >>> Justin >>> >>> >>> On 11/27/07 10:18 AM, "Bill Courington" <[EMAIL PROTECTED]> wrote: >>> >>>> Is there such a thing? I've got about a zillion files in the Attachments >>>> folder and I'm pretty sure (not positive) that many of them belong to >>>> trashed messages. >>>> >>>> Bill >>>> >>>> >>>> >>>> >>> >>> >>> >>> >>> > > > > > ---------------------------------------------------------------------- Subject: Re: Script to delete orphaned attachments? From: "Ben Kennedy" <[EMAIL PROTECTED]> Date: Tue, 27 Nov 2007 17:37:11 -0800 Marlyse Comte wrote at 7:28 PM (-0600) on 11/27/07: >wanted to try this one - sounds very useful - but can't get it to >compile, it gets a hiccup on "else set theFolder to folder..." any hints >how to get it to compile? (I think I'm good on the line endings so far). Right, I found the same thing, and forgot to mention. In the fifth "paragraph", put a newline following "then" on this line: >if not (exists folder (attachFolder & msgAttachFolder as string)) then set i.e. the following "set theFolder to..." should commence on its own line. -ben -- Ben Kennedy (chief magician) zygoat creative technical services http://www.zygoat.ca ---------------------------------------------------------------------- Subject: Re: Script to delete orphaned attachments? From: "H.R. Riggs" <[EMAIL PROTECTED]> Date: Tue, 27 Nov 2007 15:56:10 -1000 Here's a challenge for those that are so inclined. I would find this useful, and I think others might as well. Write a script to do the following: 1. Go through all messages. For any message with an attachment in the Attachments folder 2. Put the attachment in a subfolder under Attachments that has the same structure as the Mail folder/subfolder that the message is in. In other words, if I have a message in Folder/Subfolder, then the related attachment would go in ~/Mail/Powermail Files/Attachments/Folder/Subfolder If the attachment has already been moved out of Attachments, the script should do nothing. Subsequent variation is: 3. A script that would do it for the selected messages only. Ron P.S. If anybody has such a thing, I would appreciate getting a copy. Ben Kennedy wrote on 11/27/07: >Marlyse Comte wrote at 7:28 PM (-0600) on 11/27/07: > >>wanted to try this one - sounds very useful - but can't get it to >>compile, it gets a hiccup on "else set theFolder to folder..." any hints >>how to get it to compile? (I think I'm good on the line endings so far). > >Right, I found the same thing, and forgot to mention. > >In the fifth "paragraph", put a newline following "then" on this line: > >>if not (exists folder (attachFolder & msgAttachFolder as string)) then set > >i.e. the following "set theFolder to..." should commence on its own line. > >-ben > >-- >Ben Kennedy (chief magician) >zygoat creative technical services >http://www.zygoat.ca > > > ---------------------------------------------------------------------- End of powermail-discuss Digest