fix generate_attachment_metadata to match correctly with month- and year-based, and flat folder structure