>> Can you tell me how I would delete the contents of the folder prior to detaching all the documents into it? (The folder needs to be in sync - if attachments are removed from the database they must be removed from the folder also).
No, the current code doesn't handle the case. That needs to be coded. And that depends a lot on the volume of data. Attachments from a database that can be in dozens at a time need to be handled differently than a database that may contain 1000s of attachments at a time. Pls specify your requirement in detail and I might be able to help.
Though a very clever trick can be that -- do your house keeping simultaneously. Store your attachment as soon as document is created in database (An agent can be trigerred to run on NEW and MODFIED since ....). Also, you may write a database level handler that runs on document deletion. You may get rid of unwanted attachments from the file system by trapping PostDelete event of database.
>> You mentioned that I should avoid between 1-4 a.m. Why? This seems like the ideal time to do it actually...
You got it right, That does seem like the ideal time to do such things. And precisely the reason Domino has chosen that time to do all the house keeping it does. Not that Domino won't run your agents if you schedule at that time. But yes, you can keep it much happier if you don't disturb it while it works to keep the service in shape.
>> if there are two attachments in separate documents with the same name, will this code create two different files or will one overwrite the other? Based on my interpreration of the code, it looks like it's going to name it using like this: PATH\FILENAME(NOTEID).EXT - if so, then that's great.
That has to be the approach. If it doesn't already do that, try modifying it. If you yourself can't, we will help.
>> Finally, how does Notes handle thread priority? Will the server be really sluggish while this is running?
Not really. Unless and untill you have 100s of 1000s of documents and they all contain a couple attachments, you won't be overwhelmng the server. If users try lookups on views while such an agent is running, they may expericence some lag, but that's natural. You can't avoid it. For smaller databases, you might not even notice it.