I'm not sure if the 40D is supposed to work this way or not, but I don't think it is...
Last weekend my 40D rolled over 9999 images. When it did, it started numbering at 0001 in folder 101. At 101-0137 it reverted to folder 100 and no matter what I do I can't get it back to number in Folder 101. I've tried manually renumbering the folder to 101 in my computer, I updated the firmware to V. 1.1.1, I've formatted the card in the computer and tried different cards and no matter what I do it always reverts to folder 100 when I format the card in the camera. The image number sequence continues, but the folder is always 100. Am I making sense here? Shouldn't it just create a new folder every time it reaches 9999 so the numbers are 100-XXXX, 101-XXXX, 102-XXXX? My 20D worked that way but it creates a new folder for every 100 images. Is there something wrong with the camera that requires me to send it in? It's still in warranty until June.
Just a thought based on very limited knowledge/experience of what you are describing 
I really liked the way my since sold KM A2 did it - a new dated folder for every day it was used. Wonderfull for tracking images & dates as taken 

