macos – Delete all MacBook data except a certain folder?

I can not find a clear step by step guide on how completely delete all the data, applications, cache of my Mac (to give it to another friend), but keep a certain folder I can not do a backup otherwise (it's 40 GB and we're far from home).

I have a MacBook Pro running macOS Mojave. I have 1 folder on the desktop and I want to delete all data from the Mac, including all the applications and the cache, and leave this folder there.

We can and we must maintain the macOS Mojave as I just downloaded it.

I want really remove everything since it has a lot of garbage, cache and private keys, etc.