Thanks for the script. I fixed a minor bug in it (the counter was wrong), and enhanced it so that it would run over multiple folders. Doing this method isn't much use if you don't do all the folders that might have attachments at once.
I'll show the script a bit further down, but it still doesn't solve the problem. I have about 150,000 messages in my database. Even running the script overnight on a G5 isn't enough time. I guess we'll have to wait for Powermail engineering to come up with a way that works. Here's the script now (* This script goes through all the marked folders and changes the label on the attachments. Do this to find files in your Attachments folder that are not referenced by any email messages. Once this is complete, orphan files are the ones that are not set to the label setting "2" (or whatever you change it to). This can take a while to run! *) on run tell application "PowerMail" set theContainers to current containers repeat with acontainer in theContainers set attachCount to 0 repeat with msg in every message in acontainer set attachList to attachments of msg set c to (count items of attachList) if c > 0 then set attachCount to attachCount + c repeat with attachIdx from c to 1 by -1 set attachFile to file of (item attachIdx of attachList) if exists (file of (item attachIdx of attachList)) then tell application "Finder" --change "2" to whatever setting you'd like for files that have related messages set label index of attachFile to "2" end tell end if end repeat -- attachment end if end repeat -- message --Turn this statement on if you want to see what happens in each container if attachCount > 0 then display dialog (attachCount as string) & " files were marked: " & name of acontainer giving up after 10 end repeat -- container display dialog "Done." end tell end run : >George Henne said: > >>>>How can I get rid of these zombie files? >>> >>>Move them to the trash & empty the trash. >>> >> >>The problem is not being able to trash them. It's figuring out which of >>the 6000 files in the Attachment folder are zombies. > >Search the amount of files you want to work on and use this script or similar: > >*** >This script marks files that do have related found messages in PowerMail. >Provided you have managed to find all messages, you can then order by >label and trash unmarked files in the finder. Currently it doesn't >warrant moved or deleted attachment files. > >tell application "PowerMail" > set theMessages to current messages > set attachCount to 0 > repeat with msg in theMessages > set attachList to attachments of msg > repeat with attachIdx from (count items of attachList) to 1 by > -1 > set attachCount to attachCount + (count items of > attachList) > set attachFile to file of (item attachIdx of attachList) > if exists (file of (item attachIdx of attachList)) then > tell application "Finder" > --change "2" to whatever setting you'd > like for files that have >related messages > set label index of attachFile to "2" > end tell > end if > end repeat > end repeat > display dialog (attachCount as string) & " files were marked." >end tell > >*** > >I choosed to not let the script move unmarked files to the trash, but >prefer to do it by hand after sorting by label and selecting unmarked >files. This could be added however. > >PM 5.2.1 | OS X 10.3.9 | Powerbook G4/400 | 768MB RAM | 30GB HD >