The code I posted wasn't intended as a script. It is merely a test to see if it produces the path you want from your message format. The script can come later when we have established this part.
Change it back and run it on a message and see what the message box produces. If it doesn't work as intended, send a sample message as an attachment to my web site and include your forum username in the subject, or it will be discarded.