So... here we are near the end of the year 2021. SQL Server 2022 has just been announced, miracles of both hardware and software have and continue to occur, MS finally made it so that BULK INSERT and BCP actually work with true CSV (after more than 2 decades of first appearance), and the cloud is actually a viable thing.
And, still... there is no simple, supported, DIR function and there is still no BULK EXPORT in SQL Server. There are tons of other simple but incredibly useful operability missing, as well (don't get me started on the decades old mistakes currently known as REORGANIZE and REBUILD). Instead, people are relegated to rolling their own in one form or another and not just for this type of thing.
It's pretty disgusting that, on a product that costs between 4 and 7 THOUSAND USD per core, people STILL have to resort to the likes of CLR or Powershell or buy some bloody app just to do the simple stuff when I've got a phone that will convert my words to text and a camera that will find people's faces and magical, automatic fail-over from on-premise to cloud.
I know what's next because a whole lot of people have said it before. "Well, geeee-whiz, Jeff! That's what things like SSIS are for!".
Yeah... that just made my point. 🙁