is there a way to export folder structure (in the repository, not in one site) from a 5.1 alfresco community version to 5.2 alfresco community version?
I haven't tried it but refer following url if it seems useful to you.Export and Import
This documentation is prety old, and because of that, one should be careful about using it as a reference.
Besides that, it is clearly stated, "You can only perform an import/export between compatible versions of Alfresco, which generally means the same version."
What that means is that for the original question, this is not an applicable answer.
It can be useful for other scenarios though.
This may help for exporting documents, folders and metadata to a local disk and then do the import bulk in the target:
GitHub - vprince1/alfresco-bulk-export: Automatically exported from code.google.com/p/alfresco-bulk-export
Retrieving data ...