Why createFolder never deduplicates on its own
Google Drive allows multiple folders with identical names. That is not a bug — it is a documented design choice. DriveApp.createFolder does not check for an existing folder first; it creates a new one unconditionally every time you call it. Run a script twice and you have two folders named 'Monthly Reports'. Run a daily trigger for a month and you have thirty.
The first time I hit this I was building an invoice-filing script. After a week of trigger runs I found a wall of identical folders in the root. There is no built-in deduplication and no collision error to catch — the script just silently succeeds.
The correct approach is to query first. DriveApp.getFoldersByName returns a FolderIterator, not a single folder or null. You have to call hasNext() before calling next(), or the iterator throws 'DriveApp.FolderIterator object has no more elements'.