Delete all data from MacBook except a certain folder?
Apple Support has some excellent documents on guidelines to follow before selling/giving away your Mac.


What to do before you sell, give away, or trade in your Mac.


As per this document, the best way to restore the Mac to factory settings and remove everything and reinstall macOS. This should really get rid of all user data and any user installed apps.

However, you do not wish to re-download and re-install macOS Mojave. This is what I would do if I were in your place and had similar requirement.


Start by uninstalling all the unnecessary app installed from Mac App Store and other places.
First of all, go to Launchpad, press and hold Option key and uninstall apps installed from the Mac App Store. The ones installed from the Mac App Store shows an x button towards the top left of the app icon. Simply click on the x button to uninstall it.
Download and install an app called AppCleaner. Use AppCleaner to look for and uninstall any user installed apps.
Restart the computer to make sure any recently uninstalled app is completely removed.
Uninstall any package manager such as Homebrew, MacPorts that you may have installed by following the respective uninstall instructions from their website.
You are now done uninstalling the apps. I am assuming you are an Admin user. Now proceed to delete any (all) other user account(s) that you may have on system. Select the delete the user Home folder to delete any files/data saved by them.
Create a new Admin user account by going to System Preferences app → Users &amp; Groups → (Unlocking preference by clicking on Lock icon) → Clicking on + button and creating a new Administrator account.
Copy the folder that you wish to backup from the Desktop to a folder named Shared which is present in /Users directory alongside your current users Home directory.
Make sure to also copy any files to Shared folder that you may wish to backup.
Now go to System Preferences app → iCloud and turn off Find My Mac (if enabled). This will require your Apple ID credentials to be entered.
Under iCloud system preference, click on the Sign Out button to disconnect from iCloud. Make sure to remove local copy of any data (Contacts, Reminders, Notes).
Log out of the current user, we are done cleaning up.
Log in with the newly created account and perform any preliminary configuration.
First of all, copy the directory that you backed up from your Desktop to Shared folder to a suitable location in the new users account Home directory.
Once successfully backed up, delete the directory and any other files from the Shared directory.
Now go to System Preferences app → Users &amp; Groups, unlock the preference by clicking on the lock icon, select and delete your original user account. To delete it, click on the account name and click on the - button shown towards the bottom. When prompted, choose to delete all the user data.
This should take care of your specific requirement and should give you a usable factory condition like macOS installation. You can now give it away to your friend.