Amazon S3 list of directories

I use Amazon S3 to store photos from a web site, sorted from a root in different directories and subdirectories.
I can not find the function allowing me to find the list of the repertoires.
‘ListObjects’ returns all images and hangs at 1000.
Does anyone know the function that returns only directories and subdirectories.
Thank you for your answers.

Have you tried using delimiter and prefix properties when you call the listObjects api?
This might be useful