If you use Amazon S3 and have ever wanted to get a list of all the content (including everything in sub-directories) under a path, this recursive function will do the job.

Since it’s recursive, it can be a bit slower than a standard loop if there are many sub-directories, but it is MUCH cleaner.