Automating groupfolder and subfolder creation and permissions

I’d like to do some scripts for groupfolders and groupfolders:permissions and see two issues for which you might have a solution or an idea.

ISSUE 1
groupfolders:permissions (and some other groupfolders: commands) require the parameter <folder_id>. folder_id is assigned after creation of the groupfolder and is then, apparently only visible when listing all groupfolders. So I have to grab the folder_id from that list before I can do some other commands with that groupfolder. Is there any way to automate this, or do I have to resort to tools like sed(1) or awk(1) on the groupfolders:list table to get the folder_id?

ISSUE 2
when creating a groupfolder, I would like to add immediately 3 specific subfolders to it.
How can this be done on the shell?
So far, I have to assign the groupfolder to a user, login as that user and create the subfolders, which is very inconvenient.

# create the groupfolder
occ groupfolders:create FOLDER
# show the existing groupfolders, this creates an ascii table
occ groupfolders:list
# ISSUE 1 - grab <folder_id> manually from first column - can this be automated?
# enable extended permissions on the groupfolder
occ groupfolders:permissions <folder_id> --enable
# ISSUE 2 - add 3 subfolders, currently manually - can this be automated on the shell?
# then do some assign and permissions magic …
occ groupfolders:group <folder_id> …
occ groupfolders:permissions <folder_id> …

Thanks for your pointers

Dan

ISSUE 1:
Perhaps not the most elegant or simplest solution, but it works:

export FOLDERID=$(sudo -u www-data php /var/www/nextcloud/occ groupfolders:list | grep "GROUPFOLDERNAME" | sed 's/ //g'| awk -F"|" '{print $2}')

ISSUE 2:

sudo -u www-data mkdir -m 755 /mnt/ncdata/__groupfolders/$FOLDERID/Subfolder1
sudo -u www-data mkdir -m 755 /mnt/ncdata/__groupfolders/$FOLDERID/Subfolder2
sudo -u www-data mkdir -m 755 /mnt/ncdata/__groupfolders/$FOLDERID/Subfolder3
sudo -u www-data php /var/www/nextcloud/occ groupfolders:scan $FOLDERID