How to add a directory node without adding all its contents

I want to add a directory node, but gradually reveal its contents.

This is for an NFT project where the metadata is linked as ipfs://CID/[1-10000].json. For example, if 5 NFTs have been minted, I would pin 1 to 5 such that ipfs://CID/[1-5] is retrievable while ipfs://CID/[6-10000] is not.

My poor attempt to solve this as follows

hash=$(ipfs add --quiet --pin=0 --wrap-with-directory --cid-version=1 *.json | tail -1)
ipfs block get $hash | ipfs add --cid-version=1
ipfs repo  gc # so that content is not retrievable until I individually add files
ipfs cat bafkr${hash##bafyb} | ipfs dag put --store-codec dag-pb --input-codec dag-pb

This works fine locally. I can add any n.json so that it is retrievable through dag node cid. However garbage collection removes the dag node, because it’s not pinned. I think ipfs-go doesn’t allow pinning it because it’s not populated. So I cannot retrieve it with other HTTP gateways either. Any help is appreciated.
Edit: I guess my poor attempt works somehow, but I assume there are better solutions.