This simple sliding locking mechanism should be enough to keep pets and younger children from opening your bifold doors.
Can optionally be printed with a handle on one side or both.
OpenSCAD file attached should allow a decent range of size customisation. Side thickness can be increased to improve strength.
Default dimensions:
I printed with a 0.8mm nozzle with a 0.3mm layer height to speed it up. With the default settings it took around 2 hours 20 mins. I used PLA with thinner sides and was swiftly snapped by my son trying to force the bathroom door open. Switching to PETG, increasing side thickness to 5mm and increasing the lock length seems to have made it significantly more robust. You will likely need to adjust to fit your needs.
The author marked this model as their own original creation.