create and write in multiple files and Delete files if Storage full

Hallo, i am completly newbie in this area. So i have a project: i collect sensor data via ESP-NOW, and i want to save these data in sd card.
The sensor datas are pressure, humidity, temperature and altitude
i want to format these datas in json format like this for example:
{"sensorData":[1,2,3,4]} -> 1,2,3,4 should values for sensor datas XD

Problem:
-with JsonArduino, the array will get bigger and bigger,. i want to save it in a txt file, e.g. 1.txt .
-When the array size bigger than json buffer, it will stop to write in the 1.txt and shall continiue to write in 2.txt
-So in the end many files will be created in sd card. If total size from these txt.files near the maximal capacity of sd card, some of oldest files should be deleted to free some memories

Ask:
-i cannot turn this to a flow chart with loop, how can i do that

  • now i just testing it with some scripts that i got from website like how to make jsonarray and how to create multiples files, so it is a mess, and i dont know if i should upload my script too.

Thank you so much for the help