This isn't much of a hint, but what the heck, if someone else had posted it to macosxhints.com, it would've saved me five minutes. So here ya go.
I log all of my iChats, and recently noticed that my Documents -> iChats directory was out of control. I figured it would be a good thing to file all the chats into a directory (folder) for each person I chatted with.
Read the rest of the hint for a simple Python script to do just that...
Using your favorite Terminal or GUI text editor, create this script:
#!/usr/bin/python
import sys
import os, os.path
import re
ichats_dir = os.path.join(os.getenv("HOME"), "Documents/iChats")
patterns = map(re.compile,
(
r" on \d{4}-\d{2}-\d{2} at \d{2}\.\d{2}\.chat$",
r" on \d{4}-\d{2}-\d{2} at \d{2}\.\d{2} #\d+\.chat$",
r" #\d+\.chat$",
r"\.chat$",
)
)
for chat in os.listdir(ichats_dir):
aim = None
for pattern in patterns:
if pattern.search(chat):
aim = pattern.sub("", chat)
break
if aim is None: continue
aim_dir = os.path.join(ichats_dir, aim)
if not os.path.isdir(aim_dir): os.mkdir(aim_dir)
src = os.path.join(ichats_dir, chat)
dst = os.path.join(ichats_dir, aim_dir, chat)
print "%s -> %s/%s" % (chat, aim_dir, chat)
os.rename(src, dst)
Does the job for me.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20040909161117627