@David ,
From the error message, we suggest you switch to another list with less folders(less than 5k), then run commands to compare the result.
In additon, make sure items in subfolder less than 5000, in SharePoint Online we have a list view threshold limit which is 5000, when we exceed this limit, it will cause some unexpected behaviors and performance issues.
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.