Amazon S3 list of directories

Hello,
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.
YC

Have you tried using delimiter and prefix properties when you call the listObjects api?
This might be useful
https://realguess.net/2014/05/24/amazon-s3-delimiter-and-prefix/