I need to get the count of all the media items and folders inside any media folder in media library. Then export the data to csv I am planning to write a script using SPE. Please help me on the same

For Example

A(Media Folder) - 8MB

A1 (Media Item) - 2MB

A2 (Media Item) - 2 MB

A3 (Media folder) - 4MB

A31 (Media Item) - 2 MB

A32 (Media Item) - 2MB

B(Media Folder) - 3MB

B1 (Media Item) - 1MB

B2 (Media folder) - 2MB

B21 (Media Item) - 1MB

B22 (Media Item) - 1MB