Back to Factory settings except one folder I would like to give my mac to another person after a few years.
The mac is full with private and cached data that I obviously can’t find/remember, and a lot of wasted memory usage.

I would like to delete everything and back to a "new mac", but to leave only 1 folder with some data that I want to keep on desktop.

How would I do that ?
First back up to a USB what you want to keep.

Then follow instructions from Apple how to ready your Mac.

Do not forget to Log out from iCloud, iTunes, App Store...ect..